feat: add operational Dashboard
This commit is contained in:
1 parent
4a1959ecd6
commit
b8b741ccee
23 files changed
+1278
-59
No files matched your search
@@ -314,3 +314,31 @@ class RepairCenterRepository:
|
||||
finally:
|
||||
connection.close()
|
||||
return {"items": items, "summary": summary, "location_options": options}
|
||||
|
||||
def summarize_active_repairs(self) -> dict[str, Any]:
|
||||
"""Return exact active counts without loading Repair Center rows."""
|
||||
ctes = self._ctes(show_miners=False, show_locations=False)
|
||||
connection = self._connection_factory()
|
||||
try:
|
||||
with connection.cursor(row_factory=dict_row) as cur:
|
||||
cur.execute(
|
||||
f"""
|
||||
{ctes}, active_rows AS (
|
||||
SELECT repair_status FROM candidates WHERE active
|
||||
)
|
||||
SELECT count(*)::integer AS active,
|
||||
COALESCE((SELECT jsonb_object_agg(
|
||||
status_rows.repair_status,
|
||||
status_rows.status_count
|
||||
) FROM (
|
||||
SELECT repair_status,
|
||||
count(*)::integer AS status_count
|
||||
FROM active_rows
|
||||
GROUP BY repair_status
|
||||
) AS status_rows), '{{}}'::jsonb) AS status_counts
|
||||
FROM active_rows
|
||||
"""
|
||||
)
|
||||
return dict(cur.fetchone())
|
||||
finally:
|
||||
connection.close()
|
||||
Reference in new issue
Block a user