Skip to content

Switch over to use LessonId#4431

Merged
leslieyip02 merged 26 commits into
nusmodifications:masterfrom
zehata:lesson-id
Jun 28, 2026
Merged

Switch over to use LessonId#4431
leslieyip02 merged 26 commits into
nusmodifications:masterfrom
zehata:lesson-id

Conversation

@zehata

@zehata zehata commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
  • Changes validation and serialization/deserialization logic over use V3 format
  • Reverted changes to optimiser service for it to return V1 serialization strings
  • Reverted timetable export service to accept ClassNo or LessonId

Context

This activates the LessonId introduced in #4427 to resolve #4283

Implementation

As discussed in #4387 (reply in thread)
Module lesson configs are now stored as

{
  [lessonType: LessonType]: ClassNo[],
}

for non-TA modules, and as

{
  [lessonType: LessonType]: LessonId[],
}

for TA modules
Because ClassNo does not change when the faculty modifies timetables, changes made to lessons will not cause configs to become invalid unless the ClassNo was deleted.

Migration and validation logic has been updated to migrate v1 and v2 configs.

Tested that:

  • optimiser
    https://nusmods.com/timetable/sem-2/share?CS1010E=TUT:09,SEC:2&CS1010S=REC:18,LEC:1,TUT:33
  • export service
My Timetable are working.

Other Information

Just pushing this to get Greptile to review it. Not ready for review yet.

… V3 format

- Reverted changes to optimiser service for it to return V1 serialization strings
- Reverted timetable export service to accept `ClassNo` or `LessonId`
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@zehata is attempting to deploy a commit to the modsbot's projects Team on Vercel.

A member of the Team first needs to authorize it.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.64706% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.85%. Comparing base (988c6fd) to head (219e688).
⚠️ Report is 246 commits behind head on master.

Files with missing lines Patch % Lines
website/src/utils/timetables/validation.ts 78.84% 11 Missing ⚠️
website/src/views/timetable/TimetableContent.tsx 31.25% 11 Missing ⚠️
website/src/utils/timetables/shareLinks.ts 98.19% 2 Missing ⚠️
website/src/utils/timetables/migration.ts 98.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4431      +/-   ##
==========================================
+ Coverage   54.52%   57.85%   +3.32%     
==========================================
  Files         274      316      +42     
  Lines        6076     7237    +1161     
  Branches     1455     1765     +310     
==========================================
+ Hits         3313     4187     +874     
- Misses       2763     3050     +287     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates requisite parsing so omitted course counts are treated as one-of requirements. The main changes are:

  • COURSES or MODULES without an explicit count now parses like (1).
  • Added tests for omitted counts with one course, multiple courses, and separate clauses.
  • Updated cohort-gated test expectations for the new omitted-count semantics.

Confidence Score: 5/5

No merge-blocking issues were identified in the reviewed changes.

The changes are focused and covered by updated tests for the new omitted-count parsing behavior.

T-Rex T-Rex Logs

What T-Rex did

  • Copied the lessonid-sharelinks harness into website/src and ran it with Vitest to exercise the share-links flow.
  • During the initial run, the base execution failed on the V3 contract with CS1010S v1 ClassNo input parsed to lesson indices [0,3,30].
  • A head run was performed and it passed, producing actual parsed configs and a serialized mixed share string.
  • Validated token formatting against the V1 contract; the head output uses V1 tokens REC:18 and LEC:1 with the corresponding default tokens, and the V1 ClassNo token check passed with ordering differences ignored.
  • Validated input type handling: after the head run, ClassNo strings and LessonId strings are accepted, while numeric indexes are rejected with the error 'must be a string', and the validation harness runtime script used for both commits is present.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (18): Last reviewed commit: "Merge branch 'master' into lesson-id" | Re-trigger Greptile

Comment thread website/src/utils/timetables/migration.ts Outdated
Comment thread website/src/reducers/timetables.ts Outdated
Comment thread website/src/types/timetables.ts
@zehata

zehata commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Linter didn't catch the debug console.log that was left behind...

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

Comment thread website/src/actions/timetables.ts
Comment thread website/src/utils/timetables/migration.ts Outdated
@zehata

zehata commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

I ran the tests again on my machine, and couldn't reproduce the test failure. Can we re-run the CircleCI test?

@leslieyip02 leslieyip02 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is gonna take a while. Will continue reviewing tomorrow. Mostly seems good so far though!

Comment thread website/src/actions/timetables.test.ts Outdated
Comment thread website/src/actions/timetables.ts
Comment thread website/src/types/timetables.ts
Comment thread website/src/utils/timetables/lessonHydration.ts Outdated
Comment thread website/src/utils/timetables/index.ts Outdated
- Added recovery path for empty TA module lesson configs
- Added tests for enabling TA modules
@zehata

zehata commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

I haven't actually reviewed this back yet. I'm just pushing it because I have something else to do tonight.

@leslieyip02 leslieyip02 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've finished looking at most files, and the implementations seems fine. I'm just left with sharing/serialization/deserialization. I'll give it another pass tomorrow.

* Hydrate timetable lessons with interactability info\
* See type defintion of {@link InteractableLesson} for properties added
*/
export function getInteractableLessons(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we refactor this function for better readability?

  • Extract some of the more complex boolean expressions into helpers (e.g. canBeSelectedAsActiveLesson, canBeAddedToLessonConfig, etc).
  • I'm not a fan of the triply-nested mapValues. Maybe we can extract each level to a helper (e.g. getInteractableLesson(lesson, lessonId, ...), groupInteractableLessonsByLessonId(lessonMap, ...), etc)?

Comment on lines +183 to +186
if (!isV1(lessonsIdentifier)) {
const configIsV2 = isV2(lessonsIdentifier);
const migratedLessonConfig: [ClassNo] | LessonId[] = configIsV2
? migrateLessonTypeLessonsFromLessonIndicesToLessonIds(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should split the logic in migrateModuleLessonConfig into migrateLessonConfigV1, migrateLessonConfigV2 and migrateLessonConfig for better readability.

- Removed some frivolous docstring from `interactabilityHydration.ts`, adjusted logic
@zehata

zehata commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@leslieyip02 Sorry I am making some refactors to deserialization right now Done as below

Comment thread website/src/utils/timetables/shareLinks.ts
Comment thread website/src/utils/timetables/shareLinks.ts
zehata added 3 commits June 25, 2026 22:59
When a lesson is active
- For non-TA modules, only lessons in the config will show up for other lesson types, thus `alreadyAddedToLessonConfig` is necessarily true, and the function would have returned before that check
- For TA modules, we show all lessons regardless of lesson type
Thus, whether the lesson is of the same lesson type as the active lesson does not affect the result
@zehata

zehata commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for covering for me for some of the changes.

I am still going to be doing a final manual check later, just running everything manually as a final check.

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
nusmods-export Ignored Ignored Preview Jun 28, 2026 2:14am
nusmods-website Ignored Ignored Preview Jun 28, 2026 2:14am

Request Review

@leslieyip02

leslieyip02 commented Jun 27, 2026

Copy link
Copy Markdown
Member

I've updated the export deployment to point at the website deployment. This should simplify testing the export service: https://nusmods-export-iu6oqsuwj-modsbots-projects.vercel.app/.

@zehata

zehata commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

@leslieyip02 I have done a manual check (which is by no means thorough) as a sanity check. I tested migration from v2 config with multiple populated semesters, validating a malformed config, running optimiser and the export service. I did not notice anything out of the blue, so I think it should be ok.

@leslieyip02 leslieyip02 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks for the massive effort on this issue! Let's keep monitoring this.

@leslieyip02 leslieyip02 merged commit 71beeb4 into nusmodifications:master Jun 28, 2026
7 checks passed
@zehata

zehata commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks a lot for reviewing and helping with the changes!

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.

Lessons Configs are Not Preserved When Faculty Modifies Timetable

2 participants