Repository navigation
feat(api): updated_since change feed for GET /v1/bookings (#262) - #281
dominik-myszkowski wants to merge 2 commits into
Conversation
GET /v1/bookings?updated_since=<RFC 3339> returns every booking changed at or after that instant, cancelled ones included, ordered by (updated_at, id). after_id (the last item's id) turns it into an exact keyset cursor, so ties on updated_at are neither repeated nor skipped. Combines with the existing filters and limit/offset. updated_at could not carry this before: only 5 of 23 UPDATEs on bookings set it (payment transitions, the worker releasing unpaid holds, meeting links and RSVPs did not), and the column mixed the DEFAULT's millisecond form with Go's RFC3339Nano, which don't sort lexicographically. Migration 00075 normalises existing values to whole-second RFC 3339 (the string the API returns), adds an (updated_at, id) index, and hands the column to triggers: any UPDATE of a booking, or of its attendee's RSVP, stamps it. The feed holds back the current second, so a later write in that second can't sort in behind a cursor already handed out.
There was a problem hiding this comment.
ℹ️ No critical issues — one edge case worth a look.
Approach: sound — a (updated_at, id) keyset is the right cursor, and handing updated_at to triggers is the right call: it closes the "the next UPDATE forgets the column" hole that a per-call-site fix would reopen, and 00075 normalises the mixed timestamp formats that made the column unorderable to begin with.
Reviewed changes
- Change feed on
GET /v1/bookings—updated_since/after_idbuild the keyset predicate and(updated_at, id)ordering inbooking.List; the default cancelled exclusion is lifted for feed listings;order=descand a bareafter_idare refused. - Trigger-owned
updated_at— migration00075normalises every existing row to whole-second RFC 3339, adds(updated_at, id), and installs insert/update triggers onbookingsplus an RSVP trigger onbooking_attendees, so no write path can leave the column behind. - Whole-second write paths —
Cancel,CancelByID,CancelByToken,RescheduleandReassignHostswitch from RFC3339Nano tosqlTime, matching what the triggers and the API return. - Tests — booking-level coverage for trigger bumps, cancelled inclusion, tie-walking and the held-back second; handler-level coverage for the feed over HTTP and the new 400s.
- Docs — ARCHITECTURE §9/§13 and CHANGELOG describe the feed and its role as webhook catch-up.
deepseek-v4.1-flash | 𝕏
A client that seeds its cursor from a zero time value sends 0001-01-01T00:00:00Z, which booking.ListFilter reads as no feed at all: the request got the plain listing, cancelled bookings left out, and after_id was refused. Clamp anything before the Unix epoch to it.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (since the prior pullfrog review of 7084cd6)
- Pre-epoch
updated_sinceis clamped to the Unix epoch —parseBookingListFilternow normalises any parsed instant before 1970-01-01T00:00:00Z, so a client seeding its cursor from a zerotime.Time(0001-01-01T00:00:00Z) gets a real feed — cancelled bookings included,after_idaccepted — instead of silently falling back to the ordinary listing. Since no row can carry anupdated_atearlier than the epoch, the result set is unchanged. - Regression test —
TestListBookings_updatedSinceZeroInstantIsStillAFeedasserts both halves: the zero instant returns the cancelled booking, and pairing it withafter_idreturns 200 rather thanafter_id requires updated_since. Verified it fails without the clamp.
The invariant this relies on is now "a supplied updated_since is never the zero time.Time", which the clamp establishes for every HTTP caller; the existing IsZero() presence tests in feed() and the after_id branch are consequently reachable only when the parameter is absent. go test ./internal/handler -run TestListBookings, gofmt -l and go vet ./internal/handler/ are clean on f27efd3.
deepseek-v4.1-flash | 𝕏

Implements #262: a change feed on
GET /v1/bookings, so a poller can sync exactly what changed instead of refetching the whole window and inferring cancellations from bookings disappearing.What it does
GET /v1/bookings?updated_since=<RFC 3339>returns every booking changed at or after that instant, ordered by(updated_at, id)ascending, withupdated_aton each item.after_id=<id of the last item>makes the bound an exact keyset cursor:(updated_at, id) > (updated_since, after_id). Without it the bound is inclusive, so boundary rows come back rather than getting lost.limit/offset.order=descandafter_idwithoutupdated_sinceare refused with 400.Your conditions
updated_sincelifts the defaultstatus != 'cancelled'exclusion. An explicitstatusstill narrows.updated_at. The audit found that only 5 of the 23 UPDATEs onbookingsset it. Payment transitions, the worker releasing an unpaid hold (a cancellation), meeting links inlocation_value,confirm_failed, invite fields and RSVPs did not. Fixing each call site would only hold until the next one is added, so migration00075hands the column to triggers instead: any UPDATE of a booking, or of its attendee's RSVP, stamps it whatever the statement set.(updated_at, id)cursor. The column used to mix the DEFAULT's millisecond form with Go's RFC3339Nano, which don't sort lexicographically (.<Z).00075normalises existing rows to whole-second RFC 3339, the same string the API returns, so an item'supdated_atcan be passed back verbatim. Whole seconds produce ties, whichidbreaks. The current second is held back (updated_at < now), so a tie group is complete before anyone sees it. The cost is that a change appears up to about a second late.limit/offset, and the index(updated_at, id)serves both the order and the keyset condition.Migration number
00075, following your note on #273 and #275 (00073is #273's,00074is #275's). If the merge order changes, I'll renumber.Interaction with #280 (erasure delete)
A hard-deleted booking leaves no row, so it never appears in the feed. An upcoming booking has to be cancelled first, so the feed has already reported the cancellation. ARCHITECTURE says so explicitly.
Tests
booking:updated_at, always in whole-second form;updated_atexactly once across pages;handler: the parameters end to end, plus the 400s (bad timestamp,order=desc,after_idalone).gofmt,go vet ./...,go build ./...,go test ./...andgo run ./cmd/i18n-coveragepass locally. The change has no UI part. CHANGELOG has anAddedentry.