oops2
Deploy / deploy (push) Successful in 3m12s

This commit is contained in:
twotalesanimation
2026-08-01 17:51:33 +02:00
parent e91e7bf95d
commit 404daa081e
3 changed files with 221 additions and 17 deletions
+40 -16
View File
@@ -2,6 +2,13 @@ import { z } from "zod";
import { db } from "@/lib/db";
import { Prisma } from "@prisma/client";
function isPrismaTableOrColumnMissingError(error: unknown): boolean {
if (error instanceof Prisma.PrismaClientKnownRequestError) {
return error.code === "P2021" || error.code === "P2022";
}
return false;
}
const exportManifestSchema = z.object({
shotCode: z.string().min(1),
projectCode: z.string().min(1),
@@ -152,23 +159,40 @@ export async function createRenderExport(input: {
}
export async function listExportsForQueue() {
return db.export.findMany({
where: { status: { notIn: ["SUPERSEDED", "ARCHIVED", "CANCELLED", "DELIVERED"] } },
orderBy: [{ createdAt: "desc" }],
include: {
shot: { select: { shotCode: true, shotVersion: true, project: { select: { code: true } } } },
renderJobs: { orderBy: [{ createdAt: "desc" }], take: 1 },
},
});
try {
return await db.export.findMany({
where: { status: { notIn: ["SUPERSEDED", "ARCHIVED", "CANCELLED", "DELIVERED"] } },
orderBy: [{ createdAt: "desc" }],
include: {
shot: { select: { shotCode: true, shotVersion: true, project: { select: { code: true } } } },
renderJobs: { orderBy: [{ createdAt: "desc" }], take: 1 },
},
});
} catch (error) {
// Render pipeline tables may not exist yet if Phase 1 migrations have not been applied.
if (isPrismaTableOrColumnMissingError(error)) {
return [];
}
throw error;
}
}
export async function getLatestExportForShot(shotId: string) {
return db.export.findFirst({
where: { shotId },
orderBy: [{ createdAt: "desc" }],
include: {
shot: { select: { shotCode: true, project: { select: { code: true } } } },
renderJobs: { orderBy: [{ createdAt: "desc" }], take: 1 },
},
});
try {
return await db.export.findFirst({
where: { shotId },
orderBy: [{ createdAt: "desc" }],
include: {
shot: { select: { shotCode: true, project: { select: { code: true } } } },
renderJobs: { orderBy: [{ createdAt: "desc" }], take: 1 },
},
});
} catch (error) {
if (isPrismaTableOrColumnMissingError(error)) {
return null;
}
throw error;
}
}