Cross-season /stats page (#394)#395
Merged
Merged
Conversation
The other half of the Phase A split (Part 2 = #391, shipped in 0.48.0). New top-level /stats route reading the full 157-season history through a single getCrossSeasonStats() query (SQL GROUP BY aggregates + a per-season war-outcome derivation that reuses getWarOutcome on a slim per-season slice). Three components: - Faction Threat Ranking — per-faction overall HD win rates as a faction-colored horizontal bar chart, sorted ascending (most threatening enemy first). Recharts. - War Outcomes & Streaks — total wars, victories, defeats, win rate, longest win/loss streaks with season ranges, plus a wrapping per-season outcome timeline of success/danger pills. - All-Time Records — longest war, most events, longest avg battle, most defends/attacks won; each card attributed to the season that owns the extremum. The three telemetry charts from #178 (Friendly Fire Index, Accuracy Trend, Shots per Planet) are deferred until telemetry accumulates beyond season 157 — the query already returns telemetry fields so the charts slot in cleanly later. HeaderNav and BottomNav gain a Stats entry. Built test-first throughout. lint, typecheck, 1365 unit tests and build all pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
DevTools verify ✅ — dev server restarted on :3001, /stats renders the full page:
Last gate cleared. Ready for review/merge. |
`ArchiveStats` (the archives-only extras grid that sits under the shared `StatGrid` hero) was hard-capped at `lg:grid-cols-3`, so its 4th and subsequent cards wrapped to a new row — visually inconsistent with the 6-across auto-fit grid right above it. - Swap both grid divs to use the existing `.stat-grid` class (`repeat(auto-fit, minmax(11rem, 1fr))`, same one `<StatGrid>` uses). - Make the previously-implicit dependency on `StatGrid.css` explicit by importing it in `ArchiveStats.jsx` — the component now styles itself rather than relying on `<StatGrid>` happening to render first. Both grids now breathe with the viewport identically; at typical desktop widths every extras card sits on one row. Tests + DevTools verified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
Tacked on a small archives-grid fix (e2e29a8) — |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase A Part 1 of #178 — the cross-season
/statspage. Sibling of #391 (Part 2, shipped in 0.48.0).One new
getCrossSeasonStats()query feeds every section: SQLGROUP BYaggregates overh1_event,h1_status,h1_season, andh1_statistic, plus a per-season war-outcome derivation that reusesgetWarOutcome's algorithm on a slim per-season slice (final faction states + relevant events + a synthetic any-all-3-defeated snapshot flag). The query already returns telemetry fields, so the deferred telemetry components slot in cleanly later with no DB change.Three components ship:
HeaderNavandBottomNavgain aStatsentry betweenArchivesandDocs.Deferred
The three telemetry charts originally listed in #178 (Friendly Fire Index, Accuracy Trend, Shots per Planet) are deferred —
h1_statisticcurrently exists only for season 157, so a "trend across seasons" would be a one-point chart. They become a small fast-follow once telemetry accumulates beyond season 157.Test Plan
npm run lint— cleannpm run typecheck— cleannpm run test:unit— 1365 passing across 123 files (18 new tests across the query, the three components, and the two nav entries; built test-first throughout)npm run build— succeeds; precache manifest grew 158 → 164 URLs to cover the new route/,/archives,/statsall returning 4xx) midway through verification. Recommend restartingnpm run devand visiting/statsto confirm the three sections render and the Recharts bar chart paints, before merging. Will also be visible on staging oncedevelopbuilds.🤖 Generated with Claude Code