feat(web): richer active-job rows on The Floor (source/format/tracks, stage, elapsed, error)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan
2026-07-13 22:05:07 +02:00
parent 3ec1547e10
commit 381426082e
7 changed files with 198 additions and 32 deletions
+20 -2
View File
@@ -36,7 +36,10 @@ export async function POST(request: Request) {
export async function GET() {
const [requests, releases] = await Promise.all([
prisma.request.findMany({ orderBy: { createdAt: "desc" }, include: { job: true } }),
prisma.request.findMany({
orderBy: { createdAt: "desc" },
include: { job: { include: { candidates: { select: { source: true, format: true, trackCount: true, chosen: true } } } } },
}),
prisma.monitoredRelease.findMany({ select: { artistName: true, album: true, rgMbid: true } }),
]);
const rgByKey = new Map(releases.map((mr) => [`${mr.artistName} ${mr.album}`, mr.rgMbid]));
@@ -49,7 +52,22 @@ export async function GET() {
status: r.status,
createdAt: r.createdAt,
rgMbid: rgByKey.get(`${r.artist} ${r.album}`) ?? null,
job: r.job ? { state: r.job.state, currentStage: r.job.currentStage } : null,
job: r.job
? (() => {
const cands = r.job.candidates;
const chosen = cands.find((c) => c.chosen) ?? null;
return {
state: r.job.state,
currentStage: r.job.currentStage,
attempts: r.job.attempts,
error: r.job.error,
claimedAt: r.job.claimedAt,
updatedAt: r.job.updatedAt,
candidateCount: cands.length,
chosen: chosen ? { source: chosen.source, format: chosen.format, trackCount: chosen.trackCount } : null,
};
})()
: null,
})),
});
}