Skip to content

feat: add an authenticated preference version endpoint - #666

Merged
jaspermayone merged 3 commits into
mainfrom
preference-version-polling
Oct 8, 2026
Merged

jaspermayone merged 3 commits into
mainfrom
preference-version-polling

Conversation

@Cattn

@Cattn Cattn commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Adds GET /api/user/preferences/version so the extension can check for changes every five minutes and reuse cached preferences when the version is unchanged.

This builds on the batch preference endpoint added in calendar-backend#590 and the batching and session caching introduced in calendar-extension#136. The version endpoint supplies the freshness signal the companion extension change needs to reuse those complete batch responses when opening an event editor and reload them after preferences change.

The endpoint returns an opaque SHA-256 token covering the signed-in user's event and shared calendar preferences, default lecture/lab colors, notification suppression, and resolver defaults. It detects deletions and bulk edits without relying on timestamps. Other users' changes and display-only settings do not affect the token.

The route uses existing revocable-session authentication and private, no-store responses. It reads preference projections without rendering meeting templates or triggering imports/provider sync. Database work still grows with the user's preference rows. No schema migration is required.

Schedule/catalog changes retain their existing refresh paths.

Validation

  • Companion frontend: 11 deterministic UI tests with synthetic API responses, 18 existing unit tests, and Svelte/TypeScript checks passed.
  • Backend diff checked and code reviewed against the existing resolver/authentication contracts.
  • Didn't run the code because of my laptop, I would appreciate if you tested it @jaspermayone, although it should all be good

Rollout

Merge and deploy this endpoint before the frontend's cached preference reuse becomes active. Until it is available, the frontend keeps existing per-event reads.

Related issues

  • calendar-backend#567: the original request-latency investigation behind the batching work.
  • calendar-backend#654: the broader query and caching audit. This contributes preference-request reuse and freshness checks; shared server caching and HTTP caching remain separate follow-ups.

@Cattn
Cattn requested a review from jaspermayone October 7, 2026 03:42
@Cattn Cattn self-assigned this Oct 7, 2026
@Cattn
Cattn requested a lite review from Copilot October 7, 2026 03:42
@Cattn

Cattn commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

This requires WITCodingClub/calendar-extension#186 and WITCodingClub/calendar-extension#180 to be merged

This comment was marked as resolved.

gonna be so real when I say I didn't do this one lol
@Cattn

Cattn commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

and obviously WITCodingClub/calendar-extension#187

Cattn added a commit to WITCodingClub/calendar-extension that referenced this pull request Oct 7, 2026
this allows for better caching, smarter event replacing & more!

A backend PR accompanies this. WITCodingClub/calendar-backend#666
Comment thread app/services/preference_version.rb Outdated
Comment thread app/services/preference_version.rb
Cattn added a commit to WITCodingClub/calendar-extension that referenced this pull request Oct 8, 2026
this allows for better caching, smarter event replacing & more!

A backend PR accompanies this. WITCodingClub/calendar-backend#666
@jaspermayone jaspermayone changed the title Add an authenticated preference-version endpoint feat: add an authenticated preference version endpoint Oct 8, 2026
@jaspermayone
jaspermayone merged commit 1f1fd0f into main Oct 8, 2026
4 of 5 checks passed
Cattn added a commit to WITCodingClub/calendar-extension that referenced this pull request Oct 8, 2026
* add versioning to preferences

this allows for better caching, smarter event replacing & more!

A backend PR accompanies this. WITCodingClub/calendar-backend#666

* Fix error handling in preferences loading

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Logan <thecrazykid2121@gmail.com>

* use new field for prefs

also update the tests for it

---------

Signed-off-by: Logan <thecrazykid2121@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

3 participants