import { scopeFrom } from "@/lib/research/corpus"; import { coverageOf } from "@/lib/research/coverage"; import { fail, ok } from "../_respond"; export const dynamic = "force-dynamic"; // GET ?source=&channels=a,b[&fresh=1] -> CoverageResponse (lib/research/types.ts) // // Channels × years: what the source publishes (its summaries, by upload year // and state), what the editor holds on disk (channel_coverage, through its // GET /api/ops/coverage; for the local corpus, on disk when the editor cannot // be asked -- and the answer says why), gaps over 60 days, and transcripts vs // captions where a search has counted a channel whole. The held counts are // kept five minutes per source and channel; `fresh=1` (Refresh) asks again. export async function GET(request: Request) { try { const q = new URL(request.url).searchParams; return ok(await coverageOf(scopeFrom(q), { fresh: q.get("fresh") === "1" })); } catch (e) { return fail(e); } }