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:
@@ -1,3 +1,4 @@
|
||||
export * from './admin'
|
||||
export * from './game'
|
||||
export * from './rules'
|
||||
export * from './stats'
|
||||
|
||||
51
frontend/src/types/stats.ts
Normal file
51
frontend/src/types/stats.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
export interface GameRunCount {
|
||||
gameId: number
|
||||
gameName: string
|
||||
gameColor: string | null
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface PokemonRanking {
|
||||
pokemonId: number
|
||||
name: string
|
||||
spriteUrl: string | null
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface DeathCause {
|
||||
cause: string
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface TypeCount {
|
||||
type: string
|
||||
count: number
|
||||
}
|
||||
|
||||
export interface StatsResponse {
|
||||
totalRuns: number
|
||||
activeRuns: number
|
||||
completedRuns: number
|
||||
failedRuns: number
|
||||
winRate: number | null
|
||||
avgDurationDays: number | null
|
||||
|
||||
runsByGame: GameRunCount[]
|
||||
|
||||
totalEncounters: number
|
||||
caughtCount: number
|
||||
faintedCount: number
|
||||
missedCount: number
|
||||
catchRate: number | null
|
||||
avgEncountersPerRun: number | null
|
||||
|
||||
topCaughtPokemon: PokemonRanking[]
|
||||
topEncounteredPokemon: PokemonRanking[]
|
||||
|
||||
totalDeaths: number
|
||||
mortalityRate: number | null
|
||||
topDeathCauses: DeathCause[]
|
||||
avgCatchLevel: number | null
|
||||
avgFaintLevel: number | null
|
||||
typeDistribution: TypeCount[]
|
||||
}
|
||||
Reference in New Issue
Block a user