Files
vfxreview/app/api/playlist/route.ts
T
twotalesanimation 2e9fa45580
Deploy / deploy (push) Successful in 3m31s
feat(review): flag handles in the review player (metadata only)
Renders run 8 frames past the cut at each end. Directors were flagging
glitches in unfixed handles as shot problems, so the player now marks
them — without trimming or burning anything into the EXRs/MOV/MP4.

- Version.handleHead/handleTail/pictureStartFrame, Export.handleHead/
  handleTail; migration backfills pipeline exports and their preview
  versions from the manifest's handleFrames (else 8)
- AE panel: "Includes handles [8] frames each end" -> manifest.review;
  older manifests fall back to source.handleFrames
- finalize copies handles onto the Version; worker 1.6.4 reports the
  head slate length (pictureStartSeconds), else the player infers it
  as MP4 frames - EXR frameCount
- Player: hatched HANDLE / SLATE regions and cut marks on the timeline,
  "HEAD/TAIL HANDLE · NOT IN EDIT" overlay on handle frames, HANDLE badge
  on notes, "Edit range only" toggle (default on in the client portal)
- Staff Handles editor on the review page for manual uploads/corrections

Also fixes two player bugs found while testing: timeToFrame floored
float error (every seek landed a frame early), and J/reverse never ran
(the keyboard effect's cleanup stopped it on the next render).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 15:07:29 +02:00

105 lines
3.1 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,
frameCount: true,
handleHead: true,
handleTail: true,
pictureStartFrame: 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,
frameCount: latest.frameCount,
handleHead: latest.handleHead,
handleTail: latest.handleTail,
pictureStartFrame: latest.pictureStartFrame,
approvalStatus: latest.approvalStatus,
taskTitle: latest.taskTitle,
},
};
})
.filter((s): s is NonNullable<typeof s> => s !== null);
return NextResponse.json({ shots: playlist });
}