Skip to content

Commit 0366f08

Browse files
committed
Add metadata tracking for PDF creation in update process and display in run history
1 parent f7c7855 commit 0366f08

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

docker-webinterface/backend/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ async def lifespan(app: FastAPI):
106106

107107
_update_lock_file: Optional[object] = None
108108
_current_run_logs: dict[str, list] = {} # profile_name -> list of logs
109+
_current_run_metadata: dict[str, any] = {} # metadata about the current run
109110

110111

111112
def _log_progress(profile: str, stage: str, message: str = "", status: str = "info"):
@@ -299,6 +300,10 @@ async def run_update(profile_name: str | None = None):
299300
# Acquire lock to prevent concurrent updates
300301
_acquire_update_lock()
301302

303+
# Initialize run metadata
304+
global _current_run_metadata
305+
_current_run_metadata = {"pdf_created": False}
306+
302307
try:
303308
_log_progress("", "system", "Starting update process", "info")
304309

@@ -362,6 +367,7 @@ async def run_update(profile_name: str | None = None):
362367
else:
363368
# Generate PDF
364369
_log_progress(profile_name_str, "pdf_gen", "Generating PDF", "info")
370+
_current_run_metadata["pdf_created"] = True
365371
filter_args = [arg for f in profile.get("filters", []) for arg in ["-f", f]]
366372
proc = await asyncio.create_subprocess_exec(
367373
"python3", "-u", "/app/aip.py", "--cache", cache_path,
@@ -446,6 +452,7 @@ async def log_stderr():
446452
_log_progress("", "system", "Update process finished", "info")
447453
_save_run()
448454
_current_run_logs.clear()
455+
_current_run_metadata.clear()
449456
_release_update_lock()
450457

451458

@@ -520,6 +527,7 @@ def list_runs():
520527
try:
521528
data = json.loads(run_file.read_text())
522529
logs = data.get("logs", {})
530+
metadata = data.get("metadata", {})
523531

524532
# Determine overall status: "success" if all profiles completed without error, else "error"
525533
status = "success"
@@ -533,6 +541,7 @@ def list_runs():
533541
"timestamp": data.get("timestamp"),
534542
"profiles": list(logs.keys()),
535543
"status": status,
544+
"pdf_created": metadata.get("pdf_created", False),
536545
})
537546
except Exception as e:
538547
logger.error(f"Failed to read run {run_file}: {e}")
@@ -562,6 +571,7 @@ def _save_run():
562571
"id": run_id,
563572
"timestamp": run_timestamp,
564573
"logs": _current_run_logs.copy(),
574+
"metadata": _current_run_metadata.copy(),
565575
}
566576

567577
run_file = RUNS_DIR / f"{run_id}.json"

docker-webinterface/frontend/src/components/RunHistoryTable.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { api, type RunSummary, type RunDetail } from "@/lib/api";
1010
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
1111
import { Button } from "@/components/ui/button";
12+
import { Badge } from "@/components/ui/badge";
1213
import {
1314
Dialog,
1415
DialogContent,
@@ -97,6 +98,22 @@ export function RunHistoryTable({ refreshTrigger = 0 }: RunHistoryTableProps) {
9798
);
9899
},
99100
},
101+
{
102+
accessorKey: "pdf_created",
103+
header: "New PDFs",
104+
cell: ({ row }: any) => {
105+
const pdfCreated = row.getValue("pdf_created") as boolean;
106+
return pdfCreated ? (
107+
<Badge variant="default" className="bg-blue-600 hover:bg-blue-700">
108+
New PDF
109+
</Badge>
110+
) : (
111+
<Badge variant="secondary" className="text-muted-foreground">
112+
Existing
113+
</Badge>
114+
);
115+
},
116+
},
100117
{
101118
accessorKey: "profiles",
102119
header: "Profiles",

docker-webinterface/frontend/src/lib/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface RunSummary {
2222
timestamp: string;
2323
profiles: string[];
2424
status: "success" | "error";
25+
pdf_created: boolean;
2526
}
2627

2728
export interface RunDetail {

0 commit comments

Comments
 (0)