Public: anyone can read this; the crew can change it.

forked from trevato/cs

The board can be asked for one map: `/?board=<map>` renders that map's standings and says so #424

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A page showing one map's board now keeps that filter after a round, so the URL stays the state after the leaderboard refreshes. Most of #415 had already landed in #419: `?board=` is validated with `playedOn`, rendered server-side on first paint, has a sentence saying which board it is, falls back to every map with a 200 on junk, and has a "nobody has a result on this map yet" empty state. What was…

shipped production is serving it deploy ae07c2d

opened this

A page showing one map's board now keeps that filter after a round, so the URL stays the state after the leaderboard refreshes. Most of #415 had already landed in #419: ?board= is validated with playedOn, rendered server-side on first paint, has a sentence saying which board it is, falls back to every map with a 200 on junk, and has a "nobody has a result on this map yet" empty state. What was missing: when a round landed, /api/match sent back the whole board and replaced the filtered table.

  • src/pages/game.ts: <section id="stats"> carries data-board="<map>", but only when ?board= named a real map. Junk or no parameter leaves it bare.
  • src/client/report.ts, src/client/main.ts: new endpointFor(board) reads that attribute and checks it again with playedOn (same rules as the server). The reporter then posts to /api/match?board=<map>, or to plain /api/match for anything else.
  • src/gate.ts, src/server.ts: Gate.board now takes the POST's query string. The match gate renders statsHtml for playedOn(query.get("board")), so a junk value gives the whole board and never refuses the round. The range gate ignores it.
  • No CSS or inline style added, so the CSP style hash is unchanged.

Tests, all new, none changed:

  • src/server.test.ts:

- the attribute appears only for a real map; - posting with ?board=gen_cd34 and with ?board=gen_ab12 returns two different tables; - posting with a junk ?board= returns 200 and the whole board; - ?map= plays the map without filtering the board, ?board= filters without changing the map, and both together each do their own one thing.

  • src/client/report.test.ts, src/client/main.test.ts (with a board option added to stage.test-helper.ts): the post URL follows data-board, and junk posts to the plain path.
  • src/pages/game.test.ts: the section's attribute.

bun run test (typecheck plus 1758 tests) passes. /?board=gen_ab12 boots and answers 200 in about 20 ms. The README's "Compare on it" paragraph now covers the refresh.

I didn't add or change the map-link list above the table (#419 already added it, and this issue asked not to), and the day's board and the feed still aren't filtered.

To try it on the preview: open /?board=de_forge, play a round, and check that the all-time table still reads "All time on de_forge" after the result lands.

🤖 Generated with Claude Code

Closes #415

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs