caaa333f02
Deploy / deploy (push) Failing after 19m11s
Two independent features landing together: Generated shot thumbnails — a shot can now carry a thumbnail promoted from a render export (Shot.generatedThumbnailUrl/generatedThumbnailFrom) alongside the existing brief-supplied thumbnailUrl, which always takes display precedence (lib/shot-thumbnail.ts) so a promoted frame can only ever fill a gap, never overwrite the brief. Shows with pipelineConfig.autoShotThumbnail promote automatically on every finished export (lib/render-pipeline/preview.ts); promoteExportThumbnail/ clearGeneratedThumbnail (actions/shots.ts) are the manual equivalent for everyone else. Worker-side seek logic for picking the promoted frame is covered by RenderWorker/VFXReviewWorker.Tests/ThumbnailSeekTests.cs. Bulk shot delete — the shot-status page's selection bar gets a "Bulk Actions" dropdown (alongside the existing Change Due Date) with Delete Shots. bulkDeleteShots() (actions/shots.ts) deletes one at a time rather than in a single statement: exports_shotId_fkey is ON DELETE RESTRICT by design, so a shot with renders or deliveries on record is protected and gets skipped and reported by name rather than aborting the whole selection or being silently destroyed along with its history. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
97 lines
2.8 KiB
TypeScript
97 lines
2.8 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { auth } from "@/auth";
|
|
import { db } from "@/lib/db";
|
|
import { shotThumbnail } from "@/lib/shot-thumbnail";
|
|
|
|
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 });
|
|
}
|
|
|
|
// All versions are linked to tasks (taskId), not directly to shots.
|
|
// We query shots with their tasks, and for each task get the latest version.
|
|
const shots = await db.shot.findMany({
|
|
where: {
|
|
projectId,
|
|
tasks: {
|
|
some: {
|
|
versions: { some: { isLatest: true } },
|
|
},
|
|
},
|
|
},
|
|
orderBy: [{ episode: "asc" }, { scene: "asc" }, { shotNumber: "asc" }],
|
|
select: {
|
|
id: true,
|
|
shotCode: true,
|
|
episode: true,
|
|
status: true,
|
|
shotApprovalStatus: true,
|
|
sharedWithClient: true,
|
|
thumbnailUrl: true,
|
|
generatedThumbnailUrl: true,
|
|
tasks: {
|
|
select: {
|
|
id: true,
|
|
title: true,
|
|
versions: {
|
|
where: { isLatest: true },
|
|
take: 1,
|
|
orderBy: { createdAt: "desc" },
|
|
select: {
|
|
id: true,
|
|
versionNumber: true,
|
|
fileUrl: true,
|
|
thumbnailUrl: true,
|
|
posterUrl: true,
|
|
fps: true,
|
|
approvalStatus: true,
|
|
mimeType: true,
|
|
createdAt: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
// For each shot, pick the most recently uploaded latest version across all tasks
|
|
const playlist = shots
|
|
.map((shot) => {
|
|
const versions = shot.tasks
|
|
.flatMap((t) => t.versions.map((v) => ({ ...v, taskTitle: t.title })))
|
|
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
|
|
const latest = versions[0] ?? null;
|
|
if (!latest) return null;
|
|
|
|
return {
|
|
id: shot.id,
|
|
shotCode: shot.shotCode,
|
|
episode: shot.episode,
|
|
status: shot.status,
|
|
shotApprovalStatus: shot.shotApprovalStatus,
|
|
sharedWithClient: shot.sharedWithClient,
|
|
thumbnailUrl: shotThumbnail(shot),
|
|
latestVersion: {
|
|
id: latest.id,
|
|
versionNumber: latest.versionNumber,
|
|
fileUrl: latest.fileUrl,
|
|
thumbnailUrl: latest.thumbnailUrl,
|
|
posterUrl: latest.posterUrl,
|
|
fps: latest.fps,
|
|
approvalStatus: latest.approvalStatus,
|
|
taskTitle: latest.taskTitle,
|
|
},
|
|
};
|
|
})
|
|
.filter((s): s is NonNullable<typeof s> => s !== null);
|
|
|
|
return NextResponse.json({ shots: playlist });
|
|
}
|