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>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
c3a0a7b765
commit
c36b621d39
@@ -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<Metadata> {
|
||||
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 (
|
||||
<main
|
||||
className="flex flex-1 flex-col"
|
||||
style={{ "--accent": theme.accent, "--accent-soft": theme.accentSoft } as React.CSSProperties}
|
||||
>
|
||||
<AppHeader />
|
||||
<div className="mx-auto w-full max-w-4xl flex-1 px-4 py-6 sm:px-6">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<h1 className="text-2xl font-bold tracking-tight">{entry.name}</h1>
|
||||
<Badge variant="secondary">
|
||||
{theme.flagEmoji} {theme.name}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
{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."}
|
||||
</p>
|
||||
|
||||
<section className="mt-6 rounded-md border border-border/60 bg-panel p-4">
|
||||
<h2 className="mb-1 text-sm font-semibold">Fréquence des numéros</h2>
|
||||
<p className="mb-3 text-xs text-muted-foreground">
|
||||
Sur les {entry.recentDraws.length} derniers tirages — statistique descriptive seulement.
|
||||
</p>
|
||||
{frequency.length > 0 ? (
|
||||
<NumberFrequencyChart data={frequency} />
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">Pas encore assez de données.</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="mt-4 rounded-md border border-border/60 bg-panel p-4">
|
||||
<h2 className="mb-1 text-sm font-semibold">Performance de Loki dans le temps</h2>
|
||||
<p className="mb-3 text-xs text-muted-foreground">Taux de réussite cumulé, grille après grille.</p>
|
||||
{performance.length > 1 ? (
|
||||
<PerformanceChart data={performance} />
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">Pas encore assez de grilles résolues.</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="mt-4">
|
||||
<h2 className="mb-2 text-sm font-semibold">Historique des tirages</h2>
|
||||
{entry.recentDraws.length > 0 ? (
|
||||
<DrawTimeline entry={entry} />
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">Aucun tirage disponible.</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<p className="mt-6 text-[11px] text-muted-foreground">
|
||||
Données fournies par LokiLab. Statistiques descriptives seulement — aucune garantie de
|
||||
gain.
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user