Skip to content

Keep appointment ids stable on incremental re-imports; report catalog changes - #37

Merged
ydankner merged 2 commits into
mainfrom
fix/incremental-import-stable-slot-ids
Sep 22, 2026
Merged

ydankner merged 2 commits into
mainfrom
fix/incremental-import-stable-slot-ids

Conversation

@ydankner

Copy link
Copy Markdown
Collaborator

Summary

Saved semester plans store hidden tutorial slots as <course id>:appointment:<appointment id>. The incremental import (#35) kept course ids stable but re-allocated parallel-group and appointment ids, so re-importing a period silently un-hid every tutorial slot students had chosen for it. This already happened once for WS 26/27: two users' 7 hidden-slot references now point at deleted appointment ids.

  • Reuse parallel-group ids keyed by (period, unit_id, group position) and appointment ids keyed by (period, unit_id, group position, appointment position) — ALMA's listing order — on incremental re-imports.
  • Print which courses were added / removed / changed (title, times, rooms, dates) against the target D1, with per-appointment details.
  • --skip-if-unchanged stops before writing anything when nothing changed — for the scheduled WS 26/27 refreshes.

Verification

  • backend/tests/test_import_alma_json_to_d1.py: 17 tests (new: re-import keeps group/appointment ids; change summary reports added/removed/changed), run against the real migration schema.
  • Read-only dry run against production.

Follow-up (not in this PR)

Repairing the 7 dangling hidden-slot references of the two affected users is a one-off data fix, done separately with approval.

🤖 Generated with Claude Code

Saved semester plans store hidden tutorial slots as
"<course id>:appointment:<appointment id>". The incremental import kept
course ids but reallocated parallel-group and appointment ids, so a
re-import of a period silently un-hid every tutorial slot students had
chosen for it.

- Reuse parallel-group ids keyed by (period, unit_id, group position) and
  appointment ids keyed by (period, unit_id, group position, position).
- Print which courses were added, removed, or changed (title, times,
  rooms, dates) against the target D1, with per-appointment details.
- --skip-if-unchanged stops before writing anything when nothing changed,
  for scheduled refreshes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Deploying studyplaner with  Cloudflare Pages  Cloudflare Pages

Latest commit: cab1eb3
Status: ✅  Deploy successful!
Preview URL: https://e300278d.studyplaner.pages.dev
Branch Preview URL: https://fix-incremental-import-stabl.studyplaner.pages.dev

View logs

The before/after check now counts saved semester-plan references (courseIds and hidden tutorial slots by appointment id) that point at no catalog row, and fails when an import increases either count. Production currently has 7 such slot references from the unrecorded WS 26/27 re-import.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ydankner
ydankner merged commit e8478ca into main Sep 22, 2026
3 checks passed
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.

1 participant