From 688443e7324a59ccc28f987ab0551559456fb645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20F=C3=B6rtsch?= Date: Wed, 15 Apr 2026 07:00:47 +0200 Subject: [PATCH] enrich GET /api/review/:id with the latest job row --- server/api/review.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/api/review.ts b/server/api/review.ts index cf17fd5..0367473 100644 --- a/server/api/review.ts +++ b/server/api/review.ts @@ -4,7 +4,7 @@ import { isOneOf, parseId } from "../lib/validate"; import { analyzeItem, assignTargetOrder } from "../services/analyzer"; import { buildCommand } from "../services/ffmpeg"; import { getItem, mapStream, normalizeLanguage, refreshItem } from "../services/jellyfin"; -import type { MediaItem, MediaStream, ReviewPlan, StreamDecision } from "../types"; +import type { Job, MediaItem, MediaStream, ReviewPlan, StreamDecision } from "../types"; const app = new Hono(); @@ -110,7 +110,7 @@ function rowToPlan(r: RawRow): ReviewPlan | null { function loadItemDetail(db: ReturnType, itemId: number) { const item = db.prepare("SELECT * FROM media_items WHERE id = ?").get(itemId) as MediaItem | undefined; - if (!item) return { item: null, streams: [], plan: null, decisions: [], command: null }; + if (!item) return { item: null, streams: [], plan: null, decisions: [], command: null, job: null }; const streams = db .prepare("SELECT * FROM media_streams WHERE item_id = ? ORDER BY stream_index") @@ -122,7 +122,15 @@ function loadItemDetail(db: ReturnType, itemId: number) { const command = plan && !plan.is_noop ? buildCommand(item, streams, decisions) : null; - return { item, streams, plan: plan ?? null, decisions, command }; + const job = db + .prepare( + `SELECT id, item_id, command, job_type, status, output, exit_code, + created_at, started_at, completed_at + FROM jobs WHERE item_id = ? ORDER BY created_at DESC LIMIT 1`, + ) + .get(itemId) as Job | undefined; + + return { item, streams, plan: plan ?? null, decisions, command, job: job ?? null }; } /**