feat(integrity): /api/system/stats exposes integrity counts

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 17:53:12 -04:00
parent 389d1bb0cf
commit c37a3c9b55
2 changed files with 44 additions and 0 deletions
+19
View File
@@ -83,6 +83,17 @@ async def system_stats():
).all()
status_counts = {row[0]: row[1] for row in status_rows}
# Integrity counts — FC-2e.
integrity_rows = (
await session.execute(
select(
ImageRecord.integrity_status,
func.count(ImageRecord.id),
).group_by(ImageRecord.integrity_status)
)
).all()
integrity_counts = {row[0]: row[1] for row in integrity_rows}
# Active batch (most recent running)
active_batch_row = (
await session.execute(
@@ -116,5 +127,13 @@ async def system_stats():
"skipped": status_counts.get("skipped", 0),
"failed": status_counts.get("failed", 0),
},
"integrity": {
"unknown": int(integrity_counts.get("unknown", 0)),
"ok": int(integrity_counts.get("ok", 0)),
"corrupt": int(integrity_counts.get("corrupt", 0)),
"failed_verification": int(
integrity_counts.get("failed_verification", 0)
),
},
"active_batch": active_batch,
})