Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor semesters to plans #858

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Refactor semesters to plans #858

wants to merge 6 commits into from

Conversation

elizabeth-tang
Copy link
Collaborator

@elizabeth-tang elizabeth-tang commented Oct 1, 2023

Summary
Remove all uses of semesters in Vuex store and in Firebase data

  • Replace references to semesters field in VuexStoreState with new schema using the new plan data type.
  • Address edge case with rendering before Vuex store is set.

10/22/23 Changes

  • Write a getter function that returns the currentPlan's semesters to reduce code redundancy
  • Delete logging statements + unnecessary comments

Remaining TODOs:

  • Stub in rest of multiple plans functionality

Test Plan

  • After running migration script on all users/just your username if testing, does the app load with 1 plan?
  • Does adding a new plan show up for you on Firebase?
  • Does adding a new semester or classes to a semester update the correct plan on Firebase?

@elizabeth-tang elizabeth-tang requested a review from a team as a code owner October 1, 2023 23:42
@dti-github-bot
Copy link
Member

dti-github-bot commented Oct 1, 2023

[diff-counting] Significant lines: 238.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2023

Visit the preview URL for this PR (updated for commit bbf321e):

https://cornelldti-courseplan-dev--pr858-refactor-sems-s7voxvuv.web.app

(expires Tue, 21 Nov 2023 23:37:53 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6d4e0437c4559ed895272bbd63991394f1e0e933

Copy link
Collaborator

@andxu282 andxu282 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just some clean up items, I would do a command f for semesters just in case you missed something, did you ever end up fixing that bug btw?

@@ -107,7 +107,14 @@ export default defineComponent({
},
computed: {
semesters(): readonly FirestoreSemester[] {
return store.state.semesters;
console.log(store.state.plans);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of console log

};
type FirestoreOverriddenFulfillmentChoices = {
readonly [courseUniqueId: string]: FirestoreCourseOptInOptOutChoices;
};

type FirestoreUserData = {
readonly name: FirestoreUserName;
readonly semesters: FirestoreSemester[];
// readonly semesters: readonlyFirestoreSemester[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

src/store.ts Outdated
updateDoc(doc(fb.semestersCollection, simplifiedUser.email), {
plans: [{ semesters }], // TODO: andxu282 update later
plans: [plan], // TODO: andxu282 update later
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u get rid of comment 🥲

src/store.ts Outdated
@@ -300,7 +337,7 @@ export const initializeFirestoreListeners = (onLoad: () => void): (() => void) =
store.commit('setSemesters', [newSemester]);
setDoc(doc(fb.semestersCollection, simplifiedUser.email), {
orderByNewest: true,
plans: [{ semesters: [newSemester] }], // TODO: andxu282 update later
plans: [{ name: 'Plan 1', semesters: [newSemester] }], // TODO: andxu282 update later
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment : )

src/store.ts Outdated
@@ -76,7 +78,7 @@ const store: TypedVuexStore = new TypedVuexStore({
tookSwim: 'no',
},
orderByNewest: true,
semesters: [],
// semesters: [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

src/store.ts Outdated
@@ -36,7 +36,7 @@ export type VuexStoreState = {
currentFirebaseUser: SimplifiedFirebaseUser;
userName: FirestoreUserName;
onboardingData: AppOnboardingData;
semesters: readonly FirestoreSemester[];
// semesters: readonly FirestoreSemester[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

Copy link
Collaborator

@zachary-kent zachary-kent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would probably be easier and cleaner if you modified the semesters getter to return plans[currentPlan].semesters. That way, accesses to store.state.semesters wouldn't have to be changed throughout the codebase.

Copy link
Collaborator

@zachary-kent zachary-kent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing the current plan into functions like addCourseToSemester and deleteCourseFromSemesters, can we import the vuex store and access the current plan directly inside of these functions?

Copy link
Collaborator

@zachary-kent zachary-kent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can you delete the spurious console statements?

@@ -455,15 +470,28 @@ export default defineComponent({
this.openConfirmationModal(`Added ${course.code} to ${this.season} ${this.year}`);
},
deleteCourseWithoutModal(uniqueID: number) {
deleteCourseFromSemester(this.year, this.season, uniqueID, this.$gtag);
deleteCourseFromSemester(
store.state.currentPlan,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to pass the current plan as an argument?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there's no case where you aren't deleting from the current plan currently but it was just the way I wrote the firestore functions to modify the plan that is passed in.

Copy link
Collaborator

@zachary-kent zachary-kent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple plans dropdown openclose (failed)
It looks like the test is failing because the dropdown isn't opened after it's clicked.

@andxu282 andxu282 mentioned this pull request Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants