/** * GreatestHits — curated list of the most-cited events in the corpus. * * Shows the top N events by `total_mentions` from public.entities, which * surfaces the historical anchors: Kenneth Arnold 1947, Mantell 1948, etc. * Each card is an editorial teaser linking to the event entity page. */ import Link from "next/link"; import { pgQuery } from "@/lib/retrieval/db"; interface EventRow { entity_id: string; canonical_name: string; total_mentions: number; } /** * Parse "EV-1947-06-24-kenneth-arnold-sighting" → { year, slug }. * Returns null when the entity_id doesn't follow the canonical pattern. */ function parseEventId(id: string): { year: number | null; slug: string } { const m = id.match(/^EV-(\d{4})-(?:\d{2}|XX)-(?:\d{2}|XX)-(.+)$/i); if (!m) return { year: null, slug: id }; return { year: parseInt(m[1], 10), slug: m[2] }; } export async function GreatestHits({ locale, limit = 9 }: { locale: "pt-br" | "en"; limit?: number }) { const rows = await pgQuery( `SELECT entity_id, canonical_name, total_mentions FROM public.entities WHERE entity_class = 'event' AND total_mentions >= 2 AND canonical_name NOT ILIKE '%unspecified%' AND canonical_name NOT ILIKE '%unknown%' ORDER BY total_mentions DESC, entity_id ASC LIMIT $1`, [limit], ).catch(() => [] as EventRow[]); if (rows.length === 0) return null; return (
{locale === "en" ? "// The historical record" : "// O registro histórico"}

{locale === "en" ? "The incidents the archive keeps returning to" : "Os incidentes que o arquivo não esquece"}

{locale === "en" ? "all sightings →" : "todos os avistamentos →"}
{rows.map((r, i) => { const { year } = parseEventId(r.entity_id); return (
{year ?? "—"} {r.total_mentions} {locale === "en" ? "mentions" : "menções"}

{r.canonical_name}

#{(i + 1).toString().padStart(2, "0")}
); })}
); }