fix(awooop): surface legacy HITL backlog
All checks were successful
CD Pipeline / tests (push) Successful in 1m31s
Code Review / ai-code-review (push) Successful in 12s
CD Pipeline / build-and-deploy (push) Successful in 3m40s
CD Pipeline / post-deploy-checks (push) Successful in 1m38s

This commit is contained in:
Your Name
2026-05-25 23:46:50 +08:00
parent a21cb05af3
commit 88b19259c5
5 changed files with 284 additions and 9 deletions

View File

@@ -0,0 +1,31 @@
"""
Dashboard Metrics Service
=========================
Small DB-backed counters used by the war-room dashboard.
"""
from sqlalchemy import text
from src.core.logging import get_logger
from src.db.base import get_db_context
logger = get_logger("awoooi.dashboard_metrics")
async def fetch_pending_approval_count() -> int:
"""Read the live HITL backlog from approval_records."""
try:
async with get_db_context() as db:
result = await db.execute(
text(
"""
SELECT count(*)
FROM approval_records
WHERE upper(status::text) = 'PENDING'
"""
)
)
return int(result.scalar_one() or 0)
except Exception as exc:
logger.warning("dashboard_pending_approval_count_failed", error=str(exc))
return 0