Standardize semester type/season naming convention#546
Conversation
…nto ben/standardize-season-year-terminology
|
[diff-counting] Significant lines: 519. |
|
Visit the preview URL for this PR (updated for commit 348ee96): https://cornelldti-courseplan-dev--pr546-ben-standardize-seas-r6ofacz8.web.app (expires Sun, 31 Oct 2021 01:41:54 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
willespencer
left a comment
There was a problem hiding this comment.
Identified a bug - existing semesters will still have the "type" key in Firestore documents, but any new semester will have "season," leading to issues where seasons don't show up on CP. Need either a migration script or need to check for both of these keys in the code.
| v-for="season in seasons" | ||
| :key="season[1]" | ||
| v-for="s in seasons" | ||
| :key="s[1]" | ||
| class="selectSemester-dropdown-content-item" | ||
| @click="selectSeason(season[1])" | ||
| @click="selectSeason(s[1])" | ||
| data-cyId="newSemester-seasonItem" | ||
| > | ||
| <img | ||
| :src="season[0]" | ||
| :src="s[0]" | ||
| class="selectSemester-dropdown-content-season" | ||
| :alt="`${season[1]} icon`" | ||
| :alt="`${s[1]} icon`" | ||
| /> | ||
| {{ season[1] }} | ||
| {{ s[1] }} |
There was a problem hiding this comment.
had to rename since season is now a prop name
| getCurrentSeason(): FirestoreSemesterType { | ||
| let currentSeason: FirestoreSemesterType; | ||
| const currentMonth = new Date().getMonth(); | ||
| if (currentMonth === 0) { | ||
| currentSeason = 'Winter'; | ||
| } else if (currentMonth <= 4) { | ||
| currentSeason = 'Spring'; | ||
| } else if (currentMonth <= 7) { | ||
| currentSeason = 'Summer'; | ||
| } else { | ||
| currentSeason = 'Fall'; | ||
| } | ||
| return currentSeason; | ||
| }, |
There was a problem hiding this comment.
duplicate function in @/utilities
| export function getCurrentType(): 'WI' | 'SP' | 'SU' | 'FA' { | ||
| const currentMonth = new Date().getMonth(); | ||
| if (currentMonth === 0) return 'WI'; | ||
| if (currentMonth <= 4) return 'SP'; | ||
| if (currentMonth <= 7) return 'SU'; | ||
| return 'FA'; | ||
| } | ||
|
|
|
Just wanted to say - overall looks good to me. I want to check all the season semester functionality in depth but it's getting a little late so ill do it tmrw! |
There was a problem hiding this comment.
@vaishnavi17 's semester population doesn't seem to be working here? (I deleted my firestore data and went through onboarding again)
All other semester functionality seems to be good.

…nto ben/standardize-season-year-terminology
|
@hahnbeelee thanks for the catch. The bug existed because I hadn't merged Vaish's PR from master, it should be fixed now.
Then I will push to master!! 😄 |
…nto ben/standardize-season-year-terminology
…nto ben/standardize-season-year-terminology
| props: { | ||
| clearSemType: { type: String, required: true }, | ||
| clearSemYear: { type: Number, required: true }, | ||
| }, | ||
| emits: { | ||
| 'close-clear-sem': () => true, | ||
| 'clear-semester': (type: string, year: number) => | ||
| typeof type === 'string' && typeof year === 'number', | ||
| 'clear-semester': () => true, |
There was a problem hiding this comment.
These are redundant props because the <clear-semester> component is a child of the <semester> prop.
I think it was modeled after delete-semester, which does need a season & year passed in to delete the semester (because it is emitted to the grandparent <semester-view>). Instead, clear-semester is more similar to add-course and delete-course, despite what the naming suggests.
| // compare function for FirestoreSemester to determine which comes first by year and type/season | ||
| export const compareFirestoreSemesters = (a: FirestoreSemester, b: FirestoreSemester): number => { | ||
| if (a.type === b.type && a.year === b.year) { | ||
| return 0; | ||
| } | ||
| if (a.year > b.year) { | ||
| return -1; | ||
| } | ||
| if (a.year < b.year) { | ||
| return 1; | ||
| } | ||
| if (SeasonOrdinal[a.type] < SeasonOrdinal[b.type]) { | ||
| return 1; | ||
| } | ||
| return -1; | ||
| }; |
There was a problem hiding this comment.
We can get rid of this; sortedSemesters() has the same purpose. The only difference is that we don't modify the array directly anymore (think sorted() vs .sort(), which is good to avoid side effects & when working with readonly arrays.
| export const toggleOrderByNewest = (): boolean => { | ||
| const toggled = !store.state.orderByNewest; | ||
| store.commit('setOrderByNewest', toggled); | ||
| export const setOrderByNewest = (orderByNewest: boolean): void => { |
There was a problem hiding this comment.
Changed toggle (which set the negated boolean value) to set (which sets a specific boolean value) to simplify the code in the frontend component and unify the global-firestore-data functions (i.e. setBlah(newValue) or editBlah(updater)). It should have the same functionality.
Lmk if you have a different opinion and I can change this back!
| return value; | ||
| } | ||
|
|
||
| export default function getCurrentSeason(): FirestoreSemesterType { |
There was a problem hiding this comment.
No reason for this to be a default export
hahnbeelee
left a comment
There was a problem hiding this comment.
yerssirrrrrrrrrrrrrrrrrrrrrrrrr. so clean 🙏
willespencer
left a comment
There was a problem hiding this comment.
This is so great, thanks Ben!! Specifically tested to make sure that nothing breaks when users have the "type" prop in Firestore, and that duplicate semester prevention, re-ordering semesters, and adding courses to a semester from the req bar add modal all work as expected.
My only remaining question is if we want to write a data migration script if the code already works and handles both semester and type for existing users?
If we do choose to write it, maybe we should have a release with this change that handles both types, then run the migration script on prod so users only have season, and finally push another release that does not use type anymore, so there is never a period of time where user data does not match the prod code.
Summary
We used "semester type" before we were using TypeScript and it worked for a while, but now "type" can be very ambiguous -- meanwhile, "season" has no ambiguity and we've actually been using both terms for a while now. This pull request officially standardizes the naming convention by changing most instances of "semester type" to "semester season".
FirestoreSemesterTypetoFirestoreSemesterSeasoninuser-data.d.tsglobal-firestore-data/semesters.tsglobal-firestore-data/semesters.tsTODO
typeafter devs pull this PR. it needs to remain in some places for now; otherwise, it breaks stagingTest Plan
Verify that all semester-related functionality still works as intended.
Notes
If there are merge conflicts: accept your current changes, change "semester type" to "semester season" where appropriate, verify that the web app builds, and make sure to
npm run type-check.