import { projectRef } from "@/lib/projects"; import { clipBenchData } from "@/lib/report/benchData"; export const dynamic = "force-dynamic"; // THE CLIP BENCH'S DATA as JSON, for Play's in-place bench (components/projects/cutApp/CutApp.tsx): // GET ?project=&clip=[&take=][&from=play&at=][&order=cut] (`take`: the take Play was on, for // Back; the clip is always the draft's -- a take's clip is never benched, L3) // // The same function the bench's own page renders from (lib/report/benchData.ts), // so the bench inside Play and the one on its own page cannot disagree. A clip // that is not a clip of the cut is a 404, as the page's. export async function GET(request: Request) { const q = new URL(request.url).searchParams; const project = await projectRef(q.get("project") ?? ""); if (!project) return Response.json({ error: "no such project" }, { status: 404 }); const clip = q.get("clip") ?? ""; const search = Object.fromEntries([...q.entries()].filter(([k]) => k !== "project" && k !== "clip")); const r = await clipBenchData(project, clip, { search, order: q.get("order") === "cut" ? "cut" : "walk" }); if (!r) return Response.json({ error: `${clip} is not a clip of the cut` }, { status: 404 }); return Response.json(r, { headers: { "cache-control": "no-store" } }); }