Download src/app/api/queue/route.ts from Zero124/VR-MEDIA: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/src/app/api/queue/route.ts
- Command line
-
hf download hf://spaces/Zero124/VR-MEDIA/src/app/api/queue/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/Zero124/VR-MEDIA/resolve/main/src/app/api/queue/route.ts
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, | |
| }, | |
| }); | |
| } | |