Files
vfxreview/app/api/render/queue/route.ts
T
twotalesanimation 5e29c3b88d
Deploy / deploy (push) Successful in 3m16s
feat(pipeline): search the render queue by shot or client code
A search box above the exports table matches any part of the shot code or
client code, case-insensitively, so "UNG_114" lists a whole episode. It is
applied server-side (the table is paged there), debounced, and scopes the
summary counts too; combines with the project and status filters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 04:51:04 +02:00

36 lines
1.6 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { ExportStatus } from "@prisma/client";
import { toErrorResponse } from "@/lib/render-pipeline/errors";
import { requirePipelineUser } from "@/lib/render-pipeline/session-auth";
import { listExports } from "@/lib/render-pipeline/exports";
// ── GET /api/render/queue (E21) ──────────────────────────────────────────────
//
// Exports list for the Render Queue page. Optional filters: projectId,
// episode, status, q (shot/client code search); standard pagination. Defaults to all statuses so the queue
// page can show history too — the UI filters live states client-side.
export async function GET(req: NextRequest) {
try {
await requirePipelineUser();
const { searchParams } = new URL(req.url);
const status = searchParams.get("status") ?? undefined;
const result = await listExports({
projectId: searchParams.get("projectId") ?? undefined,
episode: searchParams.get("episode") ?? undefined,
shotId: searchParams.get("shotId") ?? undefined,
search: searchParams.get("q")?.slice(0, 100) || undefined,
status:
status && (Object.values(ExportStatus) as string[]).includes(status)
? (status as ExportStatus)
: undefined,
page: Number(searchParams.get("page") ?? "1") || 1,
limit: Number(searchParams.get("limit") ?? "50") || 50,
});
return NextResponse.json(result);
} catch (err) {
const { body, status } = toErrorResponse(err);
return NextResponse.json(body, { status });
}
}