new playlist page
Deploy / deploy (push) Failing after 2m49s

This commit is contained in:
twotalesanimation
2026-06-07 19:33:59 +02:00
parent ecaa963055
commit 0be1818ff5
4 changed files with 418 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
export async function GET(req: NextRequest) {
const session = await auth();
if (!session?.user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const projectId = req.nextUrl.searchParams.get("projectId");
if (!projectId) {
return NextResponse.json({ error: "projectId required" }, { status: 400 });
}
const shots = await db.shot.findMany({
where: {
projectId,
versions: {
some: {
shotId: { not: null },
mimeType: { startsWith: "video/" },
},
},
},
orderBy: [{ episode: "asc" }, { scene: "asc" }, { shotNumber: "asc" }],
select: {
id: true,
shotCode: true,
episode: true,
status: true,
thumbnailUrl: true,
versions: {
where: {
isLatest: true,
mimeType: { startsWith: "video/" },
},
take: 1,
select: {
id: true,
versionNumber: true,
fileUrl: true,
thumbnailUrl: true,
posterUrl: true,
fps: true,
approvalStatus: true,
},
},
},
});
// Only return shots that actually have a latest video version
const playlist = shots
.map((shot) => ({
id: shot.id,
shotCode: shot.shotCode,
episode: shot.episode,
status: shot.status,
thumbnailUrl: shot.thumbnailUrl,
latestVersion: shot.versions[0] ?? null,
}))
.filter((shot) => shot.latestVersion !== null);
return NextResponse.json({ shots: playlist });
}