Paginate the flights list with keyset cursor (audit M1) #13

Merged
ronnyandre merged 1 commit from perf/flights-pagination into main 2026-06-03 10:20:51 +02:00
Owner

From docs/audit-2026-06.md M1 (scoped to the flight-list portion). Branches off main.

What changed

  • listFlights now takes a (date, id) cursor + limit (default 50) and returns { rows, nextCursor }. Keyset pagination over the (date DESC, id DESC) order — served by flight_user_id_date_idx (confirmed via EXPLAIN QUERY PLAN) and correct under concurrent inserts/deletes (unlike OFFSET).
  • The flights list renders one page at a time with a "Load more" button; the header count shows (n+) when more remain.
  • Delete now drops the row from local state instead of invalidating the loader, so pages already loaded via "Load more" arent discarded.

Deliberately not done (per scoping decision): dashboard-aggregation caching (stale-stats/invalidation risk not worth it at personal-log scale) and list virtualization (pagination suffices; avoids a new dep).

Only flights/index.tsx consumes listFlights, so the signature change is contained. Verified: pnpm typecheck/lint/test (40/40) pass; query plan uses the index.

From `docs/audit-2026-06.md` **M1** (scoped to the flight-list portion). Branches off `main`. **What changed** - `listFlights` now takes a `(date, id)` cursor + `limit` (default 50) and returns `{ rows, nextCursor }`. **Keyset** pagination over the `(date DESC, id DESC)` order — served by `flight_user_id_date_idx` (confirmed via `EXPLAIN QUERY PLAN`) and correct under concurrent inserts/deletes (unlike OFFSET). - The flights list renders one page at a time with a **"Load more"** button; the header count shows `(n+)` when more remain. - Delete now drops the row from local state instead of invalidating the loader, so pages already loaded via "Load more" arent discarded. **Deliberately not done** (per scoping decision): dashboard-aggregation caching (stale-stats/invalidation risk not worth it at personal-log scale) and list virtualization (pagination suffices; avoids a new dep). Only `flights/index.tsx` consumes `listFlights`, so the signature change is contained. Verified: `pnpm typecheck`/`lint`/`test` (40/40) pass; query plan uses the index.
listFlights now takes a (date, id) cursor + limit (default 50) and returns
{ rows, nextCursor }, using keyset pagination over the (date DESC, id DESC)
order — served by the flight_user_id_date_idx index and correct under
concurrent inserts/deletes (unlike OFFSET). The flights list renders a page at
a time with a 'Load more' button instead of loading/rendering every row.

Delete now drops the row from local state instead of invalidating the loader,
so additional loaded pages aren't discarded. Dashboard-aggregation caching and
list virtualization intentionally skipped (not worth the risk/dep at personal
scale; see docs/audit-2026-06.md M1).
ronnyandre deleted branch perf/flights-pagination 2026-06-03 10:20:51 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ronnyandre/fliary!13
No description provided.