api update
Deploy / deploy (push) Successful in 2m33s

This commit is contained in:
twotalesanimation
2026-05-30 10:19:35 +02:00
parent 36ee62dacc
commit 15046892d1
2 changed files with 138 additions and 5 deletions
+41 -5
View File
@@ -237,7 +237,13 @@ export async function POST(req: NextRequest) {
}
}
// ── GET /api/ext/shots?projectId=... ─────────────────────────────────────────
// ── GET /api/ext/shots?projectId=...&episode=...&status=...&shotCode=... ──────
//
// Query params:
// projectId (required) CUID of the project
// episode (optional) filter by episode, e.g. 103
// status (optional) filter by ShotStatus, e.g. COMPLETE
// shotCode (optional) return a single shot by exact code
export async function GET(req: NextRequest) {
if (!isAuthorized(req)) {
@@ -250,11 +256,41 @@ export async function GET(req: NextRequest) {
return NextResponse.json({ error: "projectId is required" }, { status: 400 });
}
const episode = searchParams.get("episode") ?? undefined;
const status = searchParams.get("status") ?? undefined;
const shotCode = searchParams.get("shotCode") ?? undefined;
const shots = await db.shot.findMany({
where: { projectId },
orderBy: { createdAt: "asc" },
select: { id: true, shotCode: true, scene: true, episode: true, status: true },
where: {
projectId,
...(episode ? { episode } : {}),
...(status ? { status: status as any } : {}),
...(shotCode ? { shotCode } : {}),
},
orderBy: [{ episode: "asc" }, { scene: "asc" }, { shotNumber: "asc" }],
select: {
id: true,
shotCode: true,
scene: true,
episode: true,
shotNumber: true,
description: true,
status: true,
priority: true,
frameStart: true,
frameEnd: true,
fps: true,
dueDate: true,
createdAt: true,
updatedAt: true,
artist: {
select: { id: true, name: true, email: true },
},
_count: {
select: { versions: true, tasks: true },
},
},
});
return NextResponse.json({ shots });
return NextResponse.json({ shots, total: shots.length });
}