Files
vfxreview/app/api/dashboard/stats/route.ts
T
twotalesanimation d40ca8eb55
Deploy / deploy (push) Successful in 2m45s
API Updates
2026-07-08 14:17:03 +02:00

51 lines
1.0 KiB
TypeScript

import { NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
export async function GET() {
const session = await auth();
if (!session?.user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const [
approved,
review,
changes,
todo,
artists,
shots,
renderQueue,
] = await Promise.all([
db.shot.count({
where: { shotApprovalStatus: "CLIENT_APPROVED" },
}),
db.shot.count({
where: { status: { in: ["INTERNAL_REVIEW", "READY_FOR_CLIENT", "CLIENT_REVIEW"] } },
}),
db.shot.count({
where: { status: "REVISIONS" },
}),
db.shot.count({
where: { status: "WAITING" },
}),
db.user.count({
where: { role: "ARTIST", isActive: true },
}),
db.shot.count({}),
db.task.count({
where: { type: "RENDER", status: { not: "DONE" } },
}),
]);
return NextResponse.json({
approved,
review,
changes,
todo,
artists,
shots,
renderQueue,
});
}