feat: add course roster repository methods - #327
Draft
rileychh wants to merge 1 commit into
Draft
Conversation
Wire CourseRepository to the I-School Plus roster: watchStudents and refreshStudents fetch enrolled classmates, persist them to the Students and CourseOfferingStudents tables, and cache via a new CourseOfferings.rosterFetchedAt timestamp.
Dokploy Preview Deployment
|
PR Preview BuildsBuild Number: 1113 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements the repository/data-layer support for I-School Plus course rosters (classmates) by adding a cached roster watch/refresh flow in CourseRepository, plus the necessary database schema and helper DB action to persist rosters.
Changes:
- Add
CourseRepository.watchStudents(courseOfferingId)andrefreshStudents(courseOfferingId)to stream cached rosters and refresh them from I-School Plus with a 1-day TTL. - Add
CourseOfferings.rosterFetchedAtas the cache timestamp column for roster freshness tracking. - Add a DB helper
upsertStudentkeyed by uniquestudentId, preserving known names when incoming name is null.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/repositories/course_repository.dart | Adds roster watch/refresh logic and DB writes for course offering rosters. |
| lib/database/schema.dart | Adds rosterFetchedAt column to CourseOfferings to support roster caching TTL. |
| lib/database/database.g.dart | Drift-generated updates reflecting the new rosterFetchedAt column. |
| lib/database/actions.dart | Adds upsertStudent helper action keyed by Students.studentId. |
| AGENTS.md | Updates repository responsibility documentation to include related I-School Plus data. |
Files not reviewed (1)
- lib/database/database.g.dart: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+941
to
+947
| if (students.isEmpty) { | ||
| try { | ||
| await refreshStudents(courseOfferingId); | ||
| } catch (_) { | ||
| // Absorb: yield empty below so UI exits loading state | ||
| } | ||
| } |
Comment on lines
+989
to
+997
| final courses = await _iSchoolPlusService.getCourseList(); | ||
| for (final course in courses) { | ||
| if (course.courseNumber == number) { | ||
| return _iSchoolPlusService.getStudents(course); | ||
| } | ||
| } | ||
| // Offering not available on I-School Plus. | ||
| return <StudentDto>[]; | ||
| }, sso: [.iSchoolPlusService]); |
Member
Author
|
Drafting because NTUT's plan to migrate off i-School. |
rileychh
marked this pull request as draft
July 13, 2026 17:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires
CourseRepositoryto the I-School Plus roster (classmates), implementing the previously-stubbedgetStudents. This is the repository/data layer for course rosters — part of #226's "more query features (大綱、同學、教材、公告)" line.watchStudents(int courseOfferingId)→Stream<List<Student>>. Backed by a Drift.watch()join overCourseOfferingStudents/Students, ordered by student ID. Emits the cached roster immediately, then background-fetches when empty or stale. Follows the repo's standardwatchX/refreshXpattern; refresh errors are absorbed (stale data preferred).refreshStudents(int courseOfferingId)→ imperative counterpart. Resolves the offering number → I-School Plus handle, fetches the roster, replaces the junction rows, and stamps the newCourseOfferings.rosterFetchedAtcache timestamp.upsertStudentDB action keyed on the uniquestudentId(a null name never overwrites a known one).CourseOfferings.rosterFetchedAtcache column (1-day TTL), following the documented parent-row cache-timestamp convention.Behavior notes
studentId).mock_course_service.dartmatch the mock roster handles.Not in this PR
course_offering_student_studentindex per AGENTS.md; not added since this PR only does students-in-a-course.Docs