-
Notifications
You must be signed in to change notification settings - Fork 30
Display semester half hours as Q1/Q2 or Q3/Q4 based on semester #174
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ export type HydrantState = { | |
totalOptions: number; | ||
units: number; | ||
hours: number; | ||
hoursFirstHalf: number; | ||
hoursSecondHalf: number; | ||
Comment on lines
35
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you think about the type hours: { firstHalf: number; secondHalf: number; } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and omit the max hours, which i think we can recompute in the thing when we need to? unless we use it somewhere else |
||
warnings: Array<string>; | ||
saveId: string; | ||
saves: Array<Save>; | ||
|
@@ -47,6 +49,8 @@ export const DEFAULT_STATE: HydrantState = { | |
totalOptions: 0, | ||
units: 0, | ||
hours: 0, | ||
hoursFirstHalf: 0, | ||
hoursSecondHalf: 0, | ||
warnings: [], | ||
saveId: "", | ||
saves: [], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,20 +196,50 @@ export class State { | |
* localStorage. | ||
*/ | ||
updateState(save: boolean = true): void { | ||
// Calculate hours for each half | ||
const firstHalfHours = sum( | ||
this.selectedActivities | ||
.filter(act => { | ||
if ('rawClass' in act) { | ||
// Include if class is full semester or first half | ||
return !act.rawClass.half || act.rawClass.half === 1; | ||
} | ||
// Include all non-class activities in both halves | ||
return true; | ||
Comment on lines
+203
to
+208
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you feel about act => !('rawClass' in act) || !act.rawClass.half || act.rawClass.half === 1 or perhaps act => [
!('rawClass' in act), // non-class activity
!act.rawClass.half, // full-semester class
act.rawClass.half === 1, // first half
].some(Boolean) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is very nit-ty btw, so take it or leave it |
||
}) | ||
.map(activity => activity.hours) | ||
); | ||
|
||
const secondHalfHours = sum( | ||
this.selectedActivities | ||
.filter(act => { | ||
if ('rawClass' in act) { | ||
// Include if class is full semester or second half | ||
return !act.rawClass.half || act.rawClass.half === 2; | ||
} | ||
// Include all non-class activities in both halves | ||
return true; | ||
}) | ||
.map(activity => activity.hours) | ||
); | ||
|
||
this.callback?.({ | ||
selectedActivities: this.selectedActivities, | ||
viewedActivity: this.viewedActivity, | ||
selectedOption: this.selectedOption, | ||
totalOptions: this.options.length, | ||
units: sum(this.selectedClasses.map((cls) => cls.totalUnits)), | ||
hours: sum(this.selectedActivities.map((activity) => activity.hours)), | ||
hours: Math.max(firstHalfHours, secondHalfHours), // Use max for total hours | ||
hoursFirstHalf: firstHalfHours, | ||
hoursSecondHalf: secondHalfHours, | ||
warnings: Array.from( | ||
new Set(this.selectedClasses.flatMap((cls) => cls.warnings.messages)), | ||
), | ||
saveId: this.saveId, | ||
saves: this.saves, | ||
preferences: this.preferences, | ||
}); | ||
|
||
if (save) { | ||
this.storeSave(this.saveId, false); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might as well use ≤ directly in the string
also, what's the rationale for having ≤ here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i see the rationale for ≤
can we have a tooltip instead though?