From cbc303f7651d64d4e297b5978f00e793e148fd3f Mon Sep 17 00:00:00 2001 From: Dotty Dotter Date: Sun, 3 May 2026 22:49:13 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Admin-Queue-Ansicht=20=E2=80=94=20Daten?= =?UTF-8?q?=20wurden=20nicht=20angezeigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: Template erwartete data.running, data.queued, data.failed. API liefert aber data.jobs (mit status-Feld pro Job). Daher waren alle drei Tabellen IMMER leer, selbst bei laufenden Jobs. Fix: - jobs nach status filtern (running | queued/pending | completed | failed) - Neue Sektion "Zuletzt abgeschlossen" — vorher gar nicht angezeigt (20 completed Jobs auf dev waren unsichtbar) - 4. Stat-Kachel "Abgeschlossen (Total)" mit data.processed_total - Konfig-Info-Zeile: workers_running, max_size, avg_job_duration_seconds, estimated_wait_seconds — alles vorher ungenutzt im API-Response - Spalte "Gestartet" → "Dauer (s)" (Daten-mismatch, started_at gibt's im API nicht) - Wartende Jobs: bundesland-Spalte raus (nicht im API), durch Job-ID-Kurzform ersetzt Co-Authored-By: Claude Opus 4.7 (1M context) --- app/templates/v2/screens/admin_queue.html | 83 ++++++++++++++++++----- 1 file changed, 65 insertions(+), 18 deletions(-) diff --git a/app/templates/v2/screens/admin_queue.html b/app/templates/v2/screens/admin_queue.html index 18a6dc0..26ac41a 100644 --- a/app/templates/v2/screens/admin_queue.html +++ b/app/templates/v2/screens/admin_queue.html @@ -26,7 +26,7 @@ + +
+
Zuletzt abgeschlossen
+ + + + + + + +
+
Fehlgeschlagene Jobs
@@ -77,7 +101,7 @@
- + @@ -110,6 +134,11 @@ function renderTable(tbodyId, tableId, emptyId, rows, renderRow) { } } +function fmtDuration(seconds) { + if (seconds == null) return '—'; + return Number(seconds).toFixed(1); +} + async function refresh() { try { const resp = await fetch('/api/queue/status'); @@ -122,38 +151,56 @@ async function refresh() { firstLoad = false; } - // Statistik-Kacheln - const running = data.running || []; - const queued = data.queued || data.waiting || []; - const failed = data.failed || []; + // API-Format: { jobs: [{job_id, drucksache, status, duration, error}], pending, ... } + // Status-Werte: queued | running | completed | failed + const jobs = data.jobs || []; + const running = jobs.filter(j => j.status === 'running'); + const queued = jobs.filter(j => j.status === 'queued' || j.status === 'pending'); + const completed = jobs.filter(j => j.status === 'completed'); + const failed = jobs.filter(j => j.status === 'failed'); - document.getElementById('stat-running').textContent = running.length; - document.getElementById('stat-queued').textContent = queued.length; - document.getElementById('stat-failed').textContent = failed.length; + // Statistik-Kacheln + document.getElementById('stat-running').textContent = running.length; + document.getElementById('stat-queued').textContent = queued.length || data.pending || 0; + document.getElementById('stat-completed').textContent = data.processed_total != null ? data.processed_total : completed.length; + document.getElementById('stat-failed').textContent = data.failed_total != null ? data.failed_total : failed.length; + + // Konfig-Info + document.getElementById('cfg-workers').textContent = data.workers_running != null ? data.workers_running : (data.concurrency || '—'); + document.getElementById('cfg-maxsize').textContent = data.max_size != null ? data.max_size : '—'; + document.getElementById('cfg-avg').textContent = data.avg_job_duration_seconds != null ? data.avg_job_duration_seconds.toFixed(1) + ' s' : '—'; + document.getElementById('cfg-wait').textContent = data.estimated_wait_seconds != null ? data.estimated_wait_seconds.toFixed(0) + ' s' : '—'; // Laufende Jobs renderTable('running-rows', 'running-table', 'running-empty', running, j => ` - ${j.drucksache || j.id || '—'} + ${j.drucksache || '—'} ${j.status || 'running'} - ${fmtTime(j.started_at || j.created_at)} + ${fmtDuration(j.duration)} `); // Wartende Jobs renderTable('queued-rows', 'queued-table', 'queued-empty', queued, j => ` - ${j.drucksache || j.id || '—'} - ${j.bundesland || '—'} - ${fmtTime(j.created_at || j.enqueued_at)} + ${j.drucksache || '—'} + ${(j.job_id || '').slice(0, 8)} + `); + + // Abgeschlossene Jobs (recent) + renderTable('completed-rows', 'completed-table', 'completed-empty', completed, j => ` + + ${j.drucksache || '—'} + ${j.status || 'completed'} + ${fmtDuration(j.duration)} `); // Fehlgeschlagene Jobs renderTable('failed-rows', 'failed-table', 'failed-empty', failed, j => ` - ${j.drucksache || j.id || '—'} + ${j.drucksache || '—'} ${j.error || '—'} - ${fmtTime(j.failed_at || j.updated_at)} + ${fmtDuration(j.duration)} `); document.getElementById('refresh-indicator').textContent =