fix: respect teacher filters in random fill schedule generation - #724
fix: respect teacher filters in random fill schedule generation#724anitalves08 wants to merge 1 commit into
Conversation
✅ Deploy Preview for tts-fe-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
🌐 Netlify Preview disponível: |
| const newLockedCourses = selected?.filter((course) => course.locked) | ||
| .map((course) => course.course_id) | ||
|
|
||
| const newFilteredTeachers = selected?.map((course) => |
| const newFilteredTeachers = selected?.map((course) => | ||
| (course.filteredTeachers ?? []).join(',')).join('|') | ||
|
|
||
| const prevFilteredTeachers = courseOptions?.map((course) => |
mariana2103
left a comment
There was a problem hiding this comment.
The filter logic in getSchedulesGenerator looks correct. The generator reset on teacher filter change is missing though — one-line fix needed, plus worth confirming courseOptions is stale state for the comparison to be meaningful.
| (course.filteredTeachers ?? []).join(',')).join('|') | ||
|
|
||
| // Only update if locked courses changed | ||
| if (newLockedCourses?.join() !== lockedCourses?.join()) { |
There was a problem hiding this comment.
newFilteredTeachers and prevFilteredTeachers are computed here but never used — the condition only checks locked courses, so the generator is never reset when teacher filters change. This contradicts the PR description which lists it as one of the two goals.
| if (newLockedCourses?.join() !== lockedCourses?.join()) { | |
| if (newLockedCourses?.join() !== lockedCourses?.join() || newFilteredTeachers !== prevFilteredTeachers) { |
One thing worth double-checking before merging: this comparison assumes courseOptions holds the previous filter state (one render behind) while selected holds the new one. If courseOptions is always current, the comparison will always be equal and the reset will never fire even after this fix. Can you confirm courseOptions is stale state here?
Closes #308
What does this PR do?
The Random Fill algorithm was ignoring the teacher filters set by the user in each course's class selector.
filteredTeachersingetSchedulesGenerator()filteredTeacherschange, in addition to when locked courses change