Repository navigation
feat(events): registration gating + fullness for atlas redesign - #601
Merged
Merged
Conversation
Move `shouldFinish` + `FinishCheckInput` out of the ExpireEvents job into `src/lib/schedule/scheduleStatus.ts` so the registration endpoint can reuse the same "schedule has run out" check without cross-importing a job's internals. Behaviour is unchanged; the unit cases move alongside it. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add a stored `registrationsFull` boolean on Events so `sahaj-atlas-client` can read an event's "Full" state on by-id/list reads and the geojson feed without a per-event COUNT (feed stays O(1)) and without exposing raw registration numbers. True only for `sahaj-atlas` mode with a set limit the count has reached; false for external mode or a blank (unlimited) limit. Maintained by the Registrations create/delete hooks (recompute + write only on a real flip, so version churn stays negligible) and recomputed on an Events save when registrationMode / registrationLimit changes. `isEventFull` is the single shared definition of "full", reused by the registration gate. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds the denormalized `registrations_full` boolean (and its `_events_v` version companion), nullable with default false — existing rows read false until a registration change or capacity edit recomputes them. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
POST /api/events/:id/register now refuses a registration the event's state won't accept — external mode, an ended schedule (reuses shouldFinish), a started limited-run course, or a full event — with a stable machine-readable `code` (external_registration / event_ended / registration_closed / event_full, all 409) the Atlas widget maps to its registration-state UI. The capacity check is enforced against a live count (authoritative); the published/visible 404 and the open-event 201 path are unchanged. The gate is a pure, unit-tested helper; the error-code union is typed in the cross-repo responseTypes contract. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add the `409` response and its four machine-readable `errors[0].code` values to the hand-authored register-endpoint shim, and guard them in the custom-endpoints spec so the Atlas contract stays in lockstep. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Document the contract the Atlas widget relies on: a schedule-elapsed event is marked finished + `_status: 'draft'` by ExpireEvents, so `sahaj-atlas-client` reads a 404 (finished ⇒ 404, not an readable "Ended" doc). The pre-job window — past but still published — stays readable so the widget derives "Ended" client-side, and the register gate closes the matching registration hole. Stated in the Events collection JSDoc + finishEvent, with an Atlas read/registration summary in the architecture doc. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Cover each registration rejection (external / ended / started course / full) plus the boundary (an open-ended recurring class never closes) and the preserved 404, and the fullness signal (flip at the limit, free on delete, never-full for blank/external, capacity-edit recompute, client by-id + geojson selectability with no raw count). Elevate the fullness recompute's event write with asTrustedReq so the nested region filterOptions validation isn't rejected by the client query gate. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Parallelize the independent event read + registration count in syncEventRegistrationsFull (write-path latency). - Drop redundant .getTime() in the started-course instant comparison. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per code review: the count→create window isn't transactional, so concurrent registrations can overshoot registrationLimit by a few. Acceptable for a meditation class (not ticketed inventory); documented rather than adding a row lock / DB constraint. Behaviour unchanged. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
railway-app
Bot
temporarily deployed
to
sahajcloud / SahajCloud-pr-601
July 22, 2026 19:46
Destroyed
|
🚅 Deployed to the SahajCloud-pr-601 environment in sahajcloud
|
railway-app
Bot
temporarily deployed
to
sahajcloud / SahajCloud-pr-601
August 3, 2026 21:51
Destroyed
Reconciles #599 (registration gating + fullness) with main's #603/#604 finished-event overhaul, which landed the same shared surface differently: - shouldFinish: took main's lastDate-based implementation (src/lib/schedule/scheduleStatus.ts) over my upcomingDates-based one; the gate's event_ended check + gating.ts now use it (typed via EventScheduleInput), and pass `now` through so the gate is evaluated at a single instant. - Finished-event contract: main keeps finished events *published* (off the feeds via excludeFinishedEvents / notFinishedWhere), the opposite of my original "finished ⇒ draft ⇒ 404" note. Flipped the Item-3 docs (Events.ts JSDoc, architecture.md) to match, and removed main's minimal stopgap ended-check in registerForEvent — my full gate (with a machine-readable code) supersedes it, as main's own comment anticipated. - Events hooks: combined main's excludeFinishedEvents (beforeOperation) with my syncEventFullness (beforeChange). - OpenAPI + tests: kept my 4-code register 409 doc/test and main's geojson finished-exclusion doc/test; refreshed the gating unit fixtures for the lastDate model. - Migration: dropped my 0722 registrations_full migration and regenerated it on top of main's schedule_last_date (0730) so the snapshot chain stays cumulative → 20260803_221051_registrations_full_flag. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
railway-app
Bot
temporarily deployed
to
sahajcloud / SahajCloud-pr-601
August 3, 2026 22:37
Destroyed
The origin/main merge regenerated the registrations_full migration as 20260803 (replacing the pre-merge 20260722, so the snapshot chain stays cumulative on top of schedule_last_date). The PR-601 Railway preview DB persists across deploys and had already applied the old 20260722 migration, so a plain `ADD COLUMN` re-add threw "column already exists" and aborted the in-process boot migration → deploy 502 → all smoke specs down. Guard the DDL with IF NOT EXISTS / IF EXISTS: a no-op where the column is already present (identical boolean DEFAULT false), a clean add on a fresh prod DB. The out-of-order snapshot trap in .claude/rules/migrations.md (#566). Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
railway-app
Bot
temporarily deployed
to
sahajcloud / SahajCloud-pr-601
August 4, 2026 00:13
Destroyed
origin/main #613 (#606 Phase 2) widened tsconfig.test.json to tests/int/**, and CI type-checks this PR merged with latest main — surfacing two dormant errors in my additions: - createGatingEvent omitted the required `schedule`, so the create fell to the draft overload. Wrap it in main's `createData<'events'>` helper and give it a default `schedule` (every gating case overrides it). - registrations-fullness FUTURE_ONE_OFF had `firstDate_tz: string`; make it a `SupportedTimezones` literal (`as const`) and wrap the create in `createData`. Refs #599 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
railway-app
Bot
temporarily deployed
to
sahajcloud / SahajCloud-pr-601
August 4, 2026 00:38
Destroyed
This was referenced Aug 4, 2026
Merged
Ardnived
added a commit
that referenced
this pull request
Aug 4, 2026
The highest-timestamp snapshot on main (20260803_221051_registrations_full_flag.json) was stale: it merged in via PR #601, whose registrations_full migration was generated before #605/#608's schema landed (region level `venue`, events contact_email / address_venue_name, translations event_title). Those migrations are timestamped earlier than 0803 but merged later — the out-of-order snapshot trap in .claude/rules/migrations.md. The next migrate:create would have diffed against that stale snapshot and re-emitted the already-applied DDL. This lands a no-op migration whose regenerated .json reflects the full current schema, so the chain is healed: migrate:create now detects no changes (verified). The .ts does nothing — every column already ships in an earlier migration. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This branch was successfully deployed
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
Carries forward the three unbuilt items from #577 for the Atlas Event Display & Registration Surfaces Redesign (the CMS companion — email items already shipped via #582/#588/#589).
POST /api/events/:id/registernow refuses an event the client can read but that is closed to registration (external mode / ended / a started limited-run course / full) with a409and a stable machine-readablecodethe widget maps to its registration-state UI.registrationsFullboolean on Events, readable bysahaj-atlas-clienton by-id/list reads and the geojson feed at O(1) (no per-event COUNT), exposing capacity without raw counts.finished+_status: 'draft', so it 404s for clients; the pre-job window stays readable and the gate closes the registration hole there.Changes
src/lib/registrations/gating.ts—evaluateRegistrationGate(pure): external → ended (shouldFinish) → started-course → full, each a409+code.src/lib/registrations/fullness.ts—isEventFull(the single "full" predicate, shared by the gate and the signal) +syncEventRegistrationsFull(recompute-on-flip,asTrustedReq-elevated write).src/collections/{Registrations,Events}/hooks/syncFullness.ts— maintain the flag on registration create/delete and on capacity edits.src/lib/schedule/scheduleStatus.ts—shouldFinishextracted from ExpireEvents so the job + the gate share one definition.src/collections/Events/endpoints/responseTypes.ts—EventRegistrationErrorCodeunion (cross-repo contract);customEndpoints.tsdocuments the 409.Migration
src/migrations/20260722_190710_registrations_full_flag.tsregistrations_fullboolean toevents(+_events_vversion companion), nullable withDEFAULT false. Existing rows read false until a registration change or capacity edit recomputes them — degrades gracefully (absent/false = never full).downdrops both columns.Test Results
isEventFull, andshouldFinishspecs).event-registration(37) +registrations-fullness(7) passed — each rejection + the boundary (an open-ended recurring class never closes), the preserved 404, the flag flip/free, blank/external never-full, capacity-edit recompute, and client by-id + geojson selectability.Notes for reviewer
count → createwindow isn't transactional, so a burst of concurrent registrations can overshootregistrationLimitby a few — acceptable for a meditation class (not ticketed inventory); a hard cap would need a row lock / DB constraint. Flagged in code review and documented in the endpoint.gating.tsimports the error-code union from the deliberately self-containedresponseTypes.ts(the cross-repo contract file, no@/imports) — kept that direction so the contract stays the single source of truth; inverting it would break that file's self-containment.Closes #599
🤖 Generated with Claude Code