Skip to content

Add multi-day capacity engine and booking flow#1086

Open
stefan-burke wants to merge 2 commits intoduration-days/1-schema-typesfrom
duration-days/2-backend-engine
Open

Add multi-day capacity engine and booking flow#1086
stefan-burke wants to merge 2 commits intoduration-days/1-schema-typesfrom
duration-days/2-backend-engine

Conversation

@stefan-burke
Copy link
Copy Markdown
Member

Summary

  • dateToRange(date, durationDays): half-open range spanning N calendar days
  • Per-day SQL safety net: buildDayCapacitySql + buildCapacityCondition emits AND'd per-day clauses
  • Per-day JS preflight: expandDailyRange, everyDay, aggregateDemand, checkEventAvailability, checkBatchAvailability, hasAvailableSpots
  • Create/update paths thread durationDays through INSERT range and capacity checks
  • bookingDateFields(event, date) shared helper keeps payment + webhook flows aligned
  • recomputeEventBookingRanges + checkGroupCapAfterDurationChange (internal, exported in PR3)

No behavior change in production: all existing events have duration_days=1, so all callers pass 1 through. The engine is fully tested but not yet activatable via UI.

PR Stack

  1. duration-days/1-schema-types — schema + types + date helpers
  2. This PR — capacity engine + booking flow
  3. duration-days/3-admin-ui — admin UI + display (depends on this)

Test plan

  • Typecheck passes
  • Lint clean (547 files)
  • Full test suite passes (325 files, 5996 steps, 0 failures)
  • Multi-day capacity tests: check-batch-availability, create-attendee-atomic, has-available-spots, update-event-link, add-event-link
  • Concurrent race tests pass (atomic SQL rejects overlapping inserts)

Generated by Claude Code

claude added 2 commits May 5, 2026 02:06
Core capacity:
- `dateToRange(date, durationDays)`: half-open range spanning N days
- `buildDayCapacitySql`: single-day SQL clause for event+group cap
- `buildCapacityCondition`: per-day AND'd expansion for multi-day bookings
- Per-day JS preflight: `expandDailyRange`, `everyDay`, `aggregateDemand`
- `checkEventAvailability`: walks each day checking event+group caps
- `checkBatchAvailability`: per-day demand aggregation across batch items
- `hasAvailableSpots`: duration-aware wrapper

Attendee create/update:
- `createAttendeeAtomic`: threads durationDays into INSERT range
- `updateEventLink`: duration-aware capacity check + range update
- `addEventLink`: passes duration through
- `recomputeEventBookingRanges` + `checkGroupCapAfterDurationChange`
  (internal, exported in next PR when admin UI connects)

Booking flow:
- `bookingDateFields(event, date)`: shared date+duration extraction
- `processBooking`, webhook handler, availability API all pass duration

No behavior change in production: all existing events have
duration_days=1, so all callers pass 1 through.
…rom PR2

These functions have no callers until the admin UI PR connects them.
Keeping them here caused coverage failures (uncovered lines 83-142).
They'll be re-added in PR3 alongside their production consumer and tests.
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.

2 participants