import type { Metadata } from 'next'; import Link from 'next/link'; import { Download } from 'lucide-react'; import { PageHeader, Section, Note } from '@/components/ui/section'; import { EmptyState } from '@/components/ui/empty-state'; import { Badge } from '@/components/ui/badge'; import { listMetrics, snapshotsForMetric } from '@/lib/queries/rankings'; import { listSources } from '@/lib/queries/sources'; import { jsonLd, datasetLd } from '@/lib/seo'; import { SITE_URL } from '@/lib/site'; import { fmtDate, fmtInt, scopeLabel } from '@/lib/format'; export const metadata: Metadata = { title: 'Data downloads', description: 'Legally redistributable CancerIndex datasets: derived ranking snapshots as CSV with attribution.' }; export const revalidate = 600; export default async function DataPage() { const [metrics, sources] = await Promise.all([listMetrics(), listSources()]); const withSnaps = metrics.filter((m) => m.snapshot_count > 0); const snapshotLists = await Promise.all(withSnaps.map((m) => snapshotsForMetric(m.slug))); const datasets = withSnaps.flatMap((m, i) => (snapshotLists[i] ?? []).map((s) => ({ metric: m, snap: s }))); const redistributable = sources.filter((s) => s.redistribution === 'allowed' || s.redistribution === 'attribution'); const restricted = sources.filter((s) => !(s.redistribution === 'allowed' || s.redistribution === 'attribution')); return (
| Metric | Scope | Formula | Rows | Generated | Download |
|---|---|---|---|---|---|
| {metric.name} | {scopeLabel(snap.scope_key)} | {snap.formula_version} | {fmtInt(snap.eligible_entities)} | {fmtDate(snap.generated_at)} |
|
/api/export/rankings.csv?metric=<slug>&scope=<scope_key>.
Redistributable with attribution
{redistributable.length ? (None reviewed as redistributable yet.
)}Restricted or under review
{restricted.length ? (