-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: class item conflict indicator correct severity #330
fix: class item conflict indicator correct severity #330
Conversation
✅ Deploy Preview for tts-fe-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
69d57b1
to
b7f7dae
Compare
const classesConflictSeverity = (first: ClassInfo, second: ClassInfo): number => { | ||
let maxSeverity = 0; | ||
|
||
for (const slot of first.slots) { | ||
for (const otherSlot of second.slots) { | ||
if (schedulesConflict(slot, otherSlot)) { | ||
maxSeverity = Math.max(maxSeverity, conflictsSeverity(slot, otherSlot)); | ||
} | ||
} | ||
} | ||
|
||
return maxSeverity; | ||
} |
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.
const classesConflictSeverity = (first: ClassInfo, second: ClassInfo): number => { | |
let maxSeverity = 0; | |
for (const slot of first.slots) { | |
for (const otherSlot of second.slots) { | |
if (schedulesConflict(slot, otherSlot)) { | |
maxSeverity = Math.max(maxSeverity, conflictsSeverity(slot, otherSlot)); | |
} | |
} | |
} | |
return maxSeverity; | |
} | |
const classesConflictSeverity = (first: ClassInfo, second: ClassInfo): number => | |
first.slots.flatMap(slot => | |
second.slots | |
.filter(otherSlot => schedulesConflict(slot, otherSlot)) | |
.map(otherSlot => conflictsSeverity(slot, otherSlot)) | |
).reduce((maxSeverity, severity) => Math.max(maxSeverity, severity), 0); |
Because who needs friends when you have pure functions?
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.
I understand that the code you presented using a more functional paradigm has less lines but it becomes less readable and harder to debug because if we wanted to console log something inside one of the functions it would be a lot harder.
It is also harder because the majority of the people doesn't know well the workings of reduce
.
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.
That's why we should have PFL in the first year, ahaha
b7f7dae
to
5c26622
Compare
It changes the logic inside
ClassItem
so that in cases like the one described in #313 the triangle shows red instead of yellow.