0048. Games explorer: URL state, offset paging and UTC day filters
Source:
docs/decisions/0048-explorer-url-state-and-paging.md. Generated at build time; edit the source file.
Date: 2026-11-22. Status: accepted.
Context
Section titled “Context”The games explorer filters, sorts and pages the player’s games. With no API routes (ADR 0046, R2), the page is a server component, so all list state has to live in the URL. URLs are shared, bookmarked and tampered with, and a stale or hand-edited URL must never error or leak.
Decision
Section titled “Decision”- Param names.
tc(bullet,blitz,rapid,classical,daily),result(win,draw,loss),colour(white,black),fromandto(YYYY-MM-DD),account(a linked account uuid),sortandpage.sortisplayed-desc(the default),played-asc,accuracy-desc,accuracy-asc,opponent-descorblunders-desc. - Parsing.
parseGameQuery(params)turns the search params into aGameListQuery. Every invalid value falls back to its default on its own: an unknown time class or sort (matched against an own-key allow-list, soconstructoror__proto__never match), a repeated param, a date that is not a real calendar day between 2000 and 2100, a malformed uuid, or a page that is not a positive integer. Afromlater thantois swapped. A well-formed but foreignaccountis not rejected here;scopedAccountIdsturns it into an empty list. - Serialising.
serializeGameQuery(q)writes only valid values (enum members, real days, uuids, integer pages of at least 2) and writes the keys in a fixed order (tc, result, colour, from, to, account, sort, page) and omits defaults (no sort forplayed-desc, no page for 1), so a parse and serialise round trip is stable and URLs stay short. Any filter change resets the page to 1. - R5, offset paging.
PAGE_SIZE = 25, a 1-basedpage, and a total count shown as “Showing 26–50 of 412 games”. A page past the end clamps to the last page; an empty result is page 1 of 1. At a few hundred to a few thousand games per player,count(*)pluslimit/offsetis cheap and gives the total the copy needs; keyset paging would lose the total and the jump-to-page. - Sorting. Ties always break on
played_at desc, id, so on an unchanging set of games pages never overlap or skip. Offset paging does shift when games arrive between page loads (an import adds a game, and one row repeats on the next page); R5 accepts that for the total count and jump-to-page. Accuracy and blunders sort with nulls last in both directions: games whose analysis is not done have neither and go to the end.opponentsorts by the opponent’s rating, nulls last. - R6, UTC days.
fromandtoare inclusive UTC days:played_at >= from 00:00Zandplayed_at < (to + 1 day) 00:00Z, so a game at 23:59:59Z ontois included and one at 00:00:00Z the next day is not. Dates are shown in UTC at day precision (“12 Nov 2026”), so the filter and the display agree for every viewer.
Consequences
Section titled “Consequences”Tampered URLs render the defaults instead of an error. Players far from UTC may see a late-evening game under the next day; that is consistent across the filter and the display, and a per-user time zone can come later with its own ADR.