Dashboard: pipeline status view (Prefect flow runs + recent review actions, 30s auto-refresh); reviewed_at column

This commit is contained in:
2026-08-08 11:23:00 +10:00
parent a6d0ced949
commit 1814b5c5c4
3 changed files with 200 additions and 2 deletions

View File

@@ -132,6 +132,22 @@ def stats():
return json.dumps({"total": total, "by_status": by_status, "by_source": by_source})
@app.get("/pipeline", response_class=HTMLResponse)
def pipeline(request: Request):
"""Pipeline status: recent Prefect flow runs + recent review actions."""
import sys
if str(BASE.parent) not in sys.path:
sys.path.insert(0, str(BASE.parent))
import status_helper
runs = status_helper.get_flow_runs(limit=15)
actions = status_helper.get_recent_actions(limit=20)
return templates.TemplateResponse(
request, "pipeline.html",
{"runs": runs, "actions": actions},
)
def _set_status(sha: str, status: str, request: Request) -> HTMLResponse:
"""Update DB status ONLY — instant. File moves happen at import time."""
conn = _conn()
@@ -139,7 +155,9 @@ def _set_status(sha: str, status: str, request: Request) -> HTMLResponse:
if not row:
conn.close()
raise HTTPException(404)
conn.execute("UPDATE image_hashes SET status=? WHERE sha256=?", (status, sha))
conn.execute(
"UPDATE image_hashes SET status=?, reviewed_at=datetime('now') WHERE sha256=?",
(status, sha))
conn.commit()
row = conn.execute("SELECT * FROM image_hashes WHERE sha256=?", (sha,)).fetchone()
conn.close()
@@ -180,7 +198,9 @@ async def bulk_action(request: Request):
updated = 0
missing = 0
for sha in shas:
cur = conn.execute("UPDATE image_hashes SET status=? WHERE sha256=?", (status, sha))
cur = conn.execute(
"UPDATE image_hashes SET status=?, reviewed_at=datetime('now') WHERE sha256=?",
(status, sha))
if cur.rowcount:
updated += 1
else: