VR-MEDIA / src /app /api /queue /route.ts
Zero124's picture
VR Media Server 2.0 — latest build (custom Blomp thumbnail auto-detection + full pipeline)
5c0175e
Raw History Blame Contribute Delete
1.32 kB
// GET /api/queue — processing queue status.
import { NextResponse } from "next/server";
import { getQueueView } from "@/lib/scan-engine";
import { db } from "@/lib/db";
export const dynamic = "force-dynamic";
export async function GET() {
const [queue, recentDone, recentError] = await Promise.all([
getQueueView(),
db.queueItem.findMany({
where: { status: "done" },
orderBy: { finishedAt: "desc" },
take: 5,
include: { video: true },
}),
db.queueItem.findMany({
where: { status: "error" },
orderBy: { finishedAt: "desc" },
take: 5,
include: { video: true },
}),
]);
return NextResponse.json({
active: queue,
recentlyDone: recentDone.map((q) => ({
id: q.id,
videoId: q.videoId,
videoName: q.video?.name ?? "Unknown",
finishedAt: q.finishedAt?.toISOString() ?? null,
})),
recentErrors: recentError.map((q) => ({
id: q.id,
videoId: q.videoId,
videoName: q.video?.name ?? "Unknown",
errorMessage: q.errorMessage,
finishedAt: q.finishedAt?.toISOString() ?? null,
})),
totals: {
queued: queue.filter((q) => q.status === "queued").length,
running: queue.filter((q) => q.status === "running").length,
},
});
}