Add stats screen with backend endpoint and frontend page

Implements a dedicated /stats page showing cross-run aggregate statistics:
run overview with win rate, runs by game bar chart, encounter breakdowns,
top caught/encountered pokemon rankings, mortality analysis with death
causes, and type distribution. Backend endpoint uses aggregate SQL queries
to avoid N+1 fetching.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-07 20:46:36 +01:00
parent 78d31f2856
commit fb90410055
12 changed files with 700 additions and 13 deletions

View File

@@ -1,11 +1,11 @@
---
# nuzlocke-tracker-9ngw
title: Stats Screen
status: todo
status: completed
type: feature
priority: normal
created_at: 2026-02-07T19:19:40Z
updated_at: 2026-02-07T19:28:49Z
updated_at: 2026-02-07T19:45:55Z
---
A dedicated stats page aggregating data across all runs. Accessible from the main navigation.
@@ -56,12 +56,12 @@ Add `GET /api/stats` that runs aggregate queries server-side and returns pre-com
- Responsive grid layout matching the existing design system (dark mode support)
## Checklist
- [ ] Add `/stats` route and page component
- [ ] Add "Stats" navigation link
- [ ] Fetch all runs with encounters (or add backend stats endpoint)
- [ ] Run Overview section (counts, win rate, duration)
- [ ] Encounter Stats section (caught/fainted/missed breakdown)
- [ ] Pokemon Rankings section (top caught, top encountered, expandable)
- [ ] Team & Deaths section (mortality, death causes, type distribution)
- [ ] Charts for region/generation/type breakdowns
- [ ] Responsive layout + dark mode styling
- [x] Add `/stats` route and page component
- [x] Add "Stats" navigation link
- [x] Fetch all runs with encounters (or add backend stats endpoint)
- [x] Run Overview section (counts, win rate, duration)
- [x] Encounter Stats section (caught/fainted/missed breakdown)
- [x] Pokemon Rankings section (top caught, top encountered, expandable)
- [x] Team & Deaths section (mortality, death causes, type distribution)
- [x] Charts for region/generation/type breakdowns
- [x] Responsive layout + dark mode styling