Files
Nazim KriandClaude Sonnet 5 c36b621d39 Add per-lottery stats page: number frequency, draw timeline, Loki's performance over time
New /loterie/[id] page, linked from each lottery's name in the results
panel. Three visualizations, all derived client-side from LokiLab's
extended army-feed (recentDraws + pickHistory) with no new math on
LokiLab's side:
- NumberFrequencyChart: bar chart of each number's appearances across
  the last ~30 draws
- PerformanceChart: Loki's cumulative win rate over time, line chart
- DrawTimeline: scannable list of recent draws with Loki's pick and
  hit highlighting where available

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-30 09:10:26 -04:00

33 lines
1016 B
TypeScript

import type { LotteryFeedEntry } from "./lokilab-feed"
export interface FrequencyPoint {
number: number
count: number
}
/** Frequency of each distinct number across recentDraws' results, sorted ascending by number. */
export function numberFrequency(entry: LotteryFeedEntry): FrequencyPoint[] {
const counts = new Map<number, number>()
for (const draw of entry.recentDraws) {
for (const n of draw.result) counts.set(n, (counts.get(n) ?? 0) + 1)
}
return [...counts.entries()].sort((a, b) => a[0] - b[0]).map(([number, count]) => ({ number, count }))
}
export interface PerformancePoint {
date: string
cumulativeWinRate: number
resolved: number
}
/** Running win-rate of Loki's picks over time, for a trend line. */
export function performanceOverTime(entry: LotteryFeedEntry): PerformancePoint[] {
let wins = 0
let resolved = 0
return entry.pickHistory.map((p) => {
resolved++
if (p.won) wins++
return { date: p.date, cumulativeWinRate: wins / resolved, resolved }
})
}