feat(delivery): record shots delivered outside the render pipeline
Deploy / deploy (push) Successful in 3m34s

Shots delivered by hand before the pipeline have no Export, so they could
never appear in a DeliveryPackage and the dashboard countdown showed them
as not delivered. Add Shot.manualDeliveredAt/ById/Note, a "Delivered
Outside Pipeline" bulk action on Shot Status (mark with the real date, or
clear), a badge on marked shots, and count them in the countdown alongside
DELIVERED EXR packages. The real date keeps the weekly rate honest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
twotalesanimation
2026-09-25 04:03:56 +02:00
parent 27f9f7ac64
commit c2509512ff
6 changed files with 253 additions and 3 deletions
+62
View File
@@ -703,6 +703,68 @@ export async function bulkAssignArtist(shotIds: string[], artistId: string | nul
return { success: true, updated: shots.length, artistName };
}
// ── Bulk Manual Delivery ──────────────────────────────────────────────────────
/**
* Record that a selection of shots was delivered outside the render pipeline
* (by hand, before packages existed), or clear that record when
* `deliveredOn` is null. The delivery countdown counts these alongside
* DELIVERED EXR packages (lib/dashboard/ops.ts).
*
* `deliveredOn` is the day the frames went out ("yyyy-MM-dd"), stored at
* noon UTC so the calendar day survives any timezone it is shown in.
*/
export async function bulkSetManualDelivery(
shotIds: string[],
deliveredOn: string | null,
note?: string,
) {
const session = await auth();
if (!session?.user) throw new Error("Unauthorized");
if (!["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role)) {
throw new Error("Insufficient permissions");
}
const ids = z.array(z.string().cuid()).parse(shotIds);
if (!ids.length) return { success: true, updated: 0 };
let deliveredAt: Date | null = null;
if (deliveredOn) {
const day = z.string().regex(/^\d{4}-\d{2}-\d{2}$/).parse(deliveredOn);
deliveredAt = new Date(`${day}T12:00:00.000Z`);
if (Number.isNaN(deliveredAt.getTime())) throw new Error("Invalid delivery date");
if (deliveredAt.getTime() > Date.now() + 24 * 60 * 60 * 1000) {
throw new Error("A delivery date can't be in the future");
}
}
const shots = await db.shot.findMany({
where: { id: { in: ids } },
select: { id: true, projectId: true },
});
if (shots.length !== ids.length) throw new Error("Some shots not found");
const trimmedNote = note?.trim() || null;
await db.shot.updateMany({
where: { id: { in: ids } },
data: deliveredAt
? {
manualDeliveredAt: deliveredAt,
manualDeliveredById: session.user.id,
manualDeliveryNote: trimmedNote,
}
: { manualDeliveredAt: null, manualDeliveredById: null, manualDeliveryNote: null },
});
for (const pid of [...new Set(shots.map((s) => s.projectId))]) {
revalidatePath(`/projects/${pid}`);
}
revalidatePath(`/shot-status`);
revalidatePath(`/dashboard`);
return { success: true, updated: shots.length };
}
// ── Bulk Delete Shots ─────────────────────────────────────────────────────────
export async function bulkDeleteShots(shotIds: string[]) {