import { countBySeverity, decisionsForSong } from "@/lib/decisions"; import { openDecisions } from "@/lib/projects"; import { isSegment } from "@/lib/browse"; export const dynamic = "force-dynamic"; // The worklist, as data. // // No cache header and force-dynamic, for the same reason the browse pages are // dynamic: the CLI scripts write these files underneath the app, so a cached // "nothing to decide" is the one answer that must never be stale. // // `?project=` narrows to one. The parameter is deliberately not called `song`, // because nothing else in this route knows what a song is. export async function GET(request: Request) { const project = new URL(request.url).searchParams.get("project"); if (project && !isSegment(project)) { return Response.json({ error: "bad project" }, { status: 400 }); } const items = project ? await decisionsForSong(project) : await openDecisions(); const projects = new Set(items.map((d) => d.project)).size; return Response.json( { items, projects, counts: countBySeverity(items) }, { headers: { "cache-control": "no-store" } }, ); }