Skip to content

feat: implement CourseRepository.getCourseTable#170

Open
rileychh wants to merge 7 commits intomainfrom
implement-get-course-table
Open

feat: implement CourseRepository.getCourseTable#170
rileychh wants to merge 7 commits intomainfrom
implement-get-course-table

Conversation

@rileychh
Copy link
Member

@rileychh rileychh commented Mar 6, 2026

Summary

  • Implement CourseRepository.getCourseTable with full DB persistence: upserts courses, teachers, classrooms, classes, offerings, junctions, and schedules in a single transaction
  • Add TTL-based caching via fetchWithTtl with a new Semesters.courseTableFetchedAt timestamp
  • Add upsert helpers in DatabaseActions for all course-related entities
  • Use Expression getter in CourseTableSlots view to alias classrooms.nameZh as classroomNameZh (avoids Drift's nameZh1 auto-disambiguation)
  • Add nameEn to Classes schema for English class names
  • Make CourseOfferings.phase and courseType nullable (phase not always present, courseType populated later from syllabus)
  • Add cascade deletes on CourseOffering FK references for clean stale offering removal
  • Remove stale offerings on refresh (dropped courses no longer in the server response)
  • Document Fetchable field categorization with Not a [Fetchable] field comments

Test plan

  • Manual verification: getCourseTable returns correct course data for a logged-in user
  • Verify TTL caching: second call within TTL returns cached data without network fetch
  • Verify refresh: true bypasses TTL and fetches fresh data
  • Verify stale offerings are removed on refresh (e.g., dropped courses disappear)

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

PR Preview Builds

Build Number: 619
Commit: 5e5785b
Message: fix: match course table spans by offering ID instead of course number

Deploy

  • Android (Firebase App Distribution)
  • iOS (TestFlight)

Android (Firebase App Distribution)

Install build 619

@rileychh rileychh force-pushed the add-course-table-view branch from e6acf72 to 2142775 Compare March 9, 2026 07:12
@rileychh rileychh force-pushed the implement-get-course-table branch from e375e88 to d6acd50 Compare March 9, 2026 07:39
@rileychh rileychh requested a review from Copilot March 9, 2026 07:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements CourseRepository.getCourseTable end-to-end: fetches the course table from the network, persists course/offering/teacher/class/classroom/schedule data into Drift in a transaction, and returns a UI-ready CourseTableData map with TTL-based caching.

Changes:

  • Add TTL caching for course tables via fetchWithTtl and a new Semesters.courseTableFetchedAt timestamp.
  • Persist course table data into Drift with new upsert helpers in DatabaseActions and cascade deletes for dependent offering rows.
  • Extend DB schema/view to support bilingual names (Courses.nameEn, Classes.nameEn) and avoid Drift column name disambiguation in CourseTableSlots.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/repositories/course_repository.dart Implements getCourseTable, network fetch + DB persistence, and course-table grid assembly with span calculation
lib/database/actions.dart Adds upsert helpers for course-related entities used by the repository transaction
lib/database/schema.dart Adds courseTableFetchedAt, Classes.nameEn, makes some offering fields nullable, and adds cascade deletes
lib/database/views.dart Updates CourseTableSlots view (semester column + classroom name alias) to support repository queries
lib/database/database.g.dart Regenerated Drift output reflecting schema/view changes
AGENTS.md Updates project status documentation to reflect implemented repository methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

bradly0cjw
bradly0cjw previously approved these changes Mar 10, 2026
Base automatically changed from add-course-table-view to main March 10, 2026 17:41
@rileychh rileychh dismissed bradly0cjw’s stale review March 10, 2026 17:41

The base branch was changed.

Categorize all nullable fields on Fetchable tables as either
non-Fetchable (populated during initial fetch) or Fetchable (populated
during detail fetch). Fix nullability for Courses.nameZh (always
present), CourseOfferings.phase and courseType. Reorder zh/en fields
consistently. Add syllabusRemarks for teacher-authored syllabus notes
distinct from system-generated course table remarks.
Fetch course table DTOs via auth, upsert courses, teachers, classrooms,
classes, and course offerings into the database, then query the
CourseTableSlots view to build CourseTableData with span computation.

Also adds nameEn to Classes schema, upsert helpers in DatabaseActions,
semester filter to CourseTableSlots view, and Expression getter to
avoid Drift's nameZh1 auto-disambiguation.
@rileychh rileychh force-pushed the implement-get-course-table branch from d6acd50 to 4085031 Compare March 10, 2026 17:42
@rileychh-dokploy-riley-ntut-npc
Copy link

rileychh-dokploy-riley-ntut-npc bot commented Mar 10, 2026

Dokploy Preview Deployment

Name Status Preview Updated (UTC)
API Docs ✅ Done Preview URL 2026-03-11T18:58:56.299Z

@rileychh rileychh marked this pull request as draft March 10, 2026 20:00
@rileychh rileychh marked this pull request as ready for review March 11, 2026 18:29
Fixes incorrect span merging for numberless entries (e.g. 班週會) where
null == null would merge unrelated courses. Also fixes stale snapshot
reads by tracking consumed slots in a separate set.
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.

4 participants