From c36b621d391a0500a475fe31a38a1b4c75f672ab Mon Sep 17 00:00:00 2001
From: Nazim Kri
Date: Fri, 30 Oct 2026 09:10:26 -0400
Subject: [PATCH] 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
---
app/loterie/[id]/page.tsx | 86 +++++++++++++++++++++++++++
components/draw-timeline.tsx | 27 +++++++++
components/lottery-mobile-card.tsx | 5 +-
components/lottery-row.tsx | 9 ++-
components/number-frequency-chart.tsx | 27 +++++++++
components/performance-chart.tsx | 32 ++++++++++
lib/chart-data.ts | 32 ++++++++++
lib/lokilab-feed.ts | 4 ++
8 files changed, 219 insertions(+), 3 deletions(-)
create mode 100644 app/loterie/[id]/page.tsx
create mode 100644 components/draw-timeline.tsx
create mode 100644 components/number-frequency-chart.tsx
create mode 100644 components/performance-chart.tsx
create mode 100644 lib/chart-data.ts
diff --git a/app/loterie/[id]/page.tsx b/app/loterie/[id]/page.tsx
new file mode 100644
index 0000000..732ba2d
--- /dev/null
+++ b/app/loterie/[id]/page.tsx
@@ -0,0 +1,86 @@
+import type { Metadata } from "next"
+import { notFound } from "next/navigation"
+import { getArmyFeed } from "@/lib/lokilab-feed"
+import { numberFrequency, performanceOverTime } from "@/lib/chart-data"
+import { countryTheme } from "@/lib/countries"
+import { AppHeader } from "@/components/app-header"
+import { NumberFrequencyChart } from "@/components/number-frequency-chart"
+import { PerformanceChart } from "@/components/performance-chart"
+import { DrawTimeline } from "@/components/draw-timeline"
+import { Badge } from "@/components/ui/badge"
+
+export const instant = false
+
+export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise {
+ const { id } = await params
+ return { title: `${id} — Statistiques LokiLoto` }
+}
+
+export default async function LotteryStatsPage({ params }: { params: Promise<{ id: string }> }) {
+ const { id } = await params
+ const feed = await getArmyFeed()
+ const entry = feed.lotteries.find((l) => l.id === id)
+ if (!entry) notFound()
+
+ const theme = countryTheme(entry.country)
+ const frequency = numberFrequency(entry)
+ const performance = performanceOverTime(entry)
+
+ return (
+
+
+
+
+
{entry.name}
+
+ {theme.flagEmoji} {theme.name}
+
+
+
+ {entry.lifetime.picksTracked > 0
+ ? `${(entry.lifetime.winRate * 100).toFixed(0)}% de réussite sur ${entry.lifetime.picksTracked} grilles suivies`
+ : "Pas encore de grilles résolues pour cette loterie."}
+
+
+
+
Fréquence des numéros
+
+ Sur les {entry.recentDraws.length} derniers tirages — statistique descriptive seulement.
+
+ {frequency.length > 0 ? (
+
+ ) : (
+
Pas encore assez de données.
+ )}
+
+
+
+
Performance de Loki dans le temps
+
Taux de réussite cumulé, grille après grille.
+ {performance.length > 1 ? (
+
+ ) : (
+
Pas encore assez de grilles résolues.
+ )}
+
+
+
+
Historique des tirages
+ {entry.recentDraws.length > 0 ? (
+
+ ) : (
+
Aucun tirage disponible.
+ )}
+
+
+
+ Données fournies par LokiLab. Statistiques descriptives seulement — aucune garantie de
+ gain.
+
+
+
+ )
+}
diff --git a/components/draw-timeline.tsx b/components/draw-timeline.tsx
new file mode 100644
index 0000000..bcf080b
--- /dev/null
+++ b/components/draw-timeline.tsx
@@ -0,0 +1,27 @@
+import { NumberSequence } from "@/components/number-sequence"
+import type { LotteryFeedEntry } from "@/lib/lokilab-feed"
+
+export function DrawTimeline({ entry }: { entry: LotteryFeedEntry }) {
+ return (
+