/** * earth-now.co * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * File: apps/web/app/methodology/page.tsx * Purpose: Public methodology page (product commitment) — per-metric source, license, cadence, model family/version, last observation, uncertainty */ import Link from "next/link"; import { formatValue } from "@earth-now/counter"; import { fetchMetrics, type MetricSummary } from "@/lib/api"; import { DEFAULT_LOCALE, formatDateUtc, isLocale, translate, type MessageKey, } from "@/lib/messages"; export const dynamic = "force-dynamic"; const PERCENT_HINTS = { decimals: 0, unit: "%" } as const; function levelLabel(metric: MetricSummary): string { const level = typeof metric.level === "number" ? `L${metric.level}` : metric.level.toUpperCase(); const version = metric.modelVersion !== undefined ? ` · ${metric.modelVersion}` : ""; return `${level} · ${metric.model}${version}`; } export default async function MethodologyPage({ searchParams, }: { searchParams?: { lang?: string }; }) { const langParam = searchParams?.lang; const locale = isLocale(langParam) ? langParam : DEFAULT_LOCALE; const t = (key: MessageKey) => translate(locale, key); let metrics: MetricSummary[] = []; let offline = false; try { metrics = await fetchMetrics(); } catch { offline = true; } return (
{t("methodology.back")}

{t("methodology.title")}

{t("methodology.intro")}

{offline ? (

{t("offline.body")}

) : (
{metrics.map((metric) => { const source = metric.sources[0]; return ( ); })}
{t("methodology.metric")} {t("methodology.domain")} {t("methodology.kind")} {t("methodology.model")} {t("methodology.source")} {t("methodology.license")} {t("methodology.cadence")} {t("methodology.observed")} {t("methodology.uncertainty")} {t("methodology.note")}
{metric.name[locale]} {metric.stale && ( {t("chip.stale")} )} {t(`domain.${metric.domain}` as MessageKey)} {t(`kind.${metric.kind}` as MessageKey)} {levelLabel(metric)} {source !== undefined ? ( {source.name} ) : ( "—" )} {source?.license ?? "—"} {source?.cadence ?? "—"} {metric.observedAt !== undefined ? formatDateUtc(metric.observedAt, locale) : "—"} {metric.uncertaintyFraction !== undefined ? `± ${formatValue(metric.uncertaintyFraction * 100, PERCENT_HINTS, { locale, })} % (${t("chip.estimate")})` : "—"} {metric.editorialNote !== undefined ? metric.editorialNote[locale] : ""}
)}
); }