fix: dashboard queries Forgejo directly for PR backlog, not just DB
Dashboard showed 1 conflict when Forgejo had 30 open PRs because it only queried pipeline.db — which misses all agent-created PRs (Rio, Leo, etc.). Now queries Forgejo API for authoritative open/unmergeable counts. Falls back to DB if Forgejo unreachable. Pentagon-Agent: Epimetheus <3D35839A-7722-4740-B93D-51157F7D5E70>
This commit is contained in:
parent
a19db22b16
commit
8ff4784fcb
1 changed files with 22 additions and 3 deletions
|
|
@ -221,12 +221,31 @@ def _compute_vital_signs(conn) -> dict:
|
||||||
"""Compute Vida's five vital signs from DB state + claim-index."""
|
"""Compute Vida's five vital signs from DB state + claim-index."""
|
||||||
|
|
||||||
# 1. Review throughput — backlog and latency
|
# 1. Review throughput — backlog and latency
|
||||||
open_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='open'").fetchone()["n"]
|
# Query Forgejo directly for authoritative PR counts (DB misses agent-created PRs)
|
||||||
conflict_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='conflict'").fetchone()["n"]
|
forgejo_open = 0
|
||||||
|
forgejo_unmergeable = 0
|
||||||
|
try:
|
||||||
|
import requests as _req
|
||||||
|
_token = Path("/opt/teleo-eval/secrets/forgejo-token").read_text().strip() if Path("/opt/teleo-eval/secrets/forgejo-token").exists() else ""
|
||||||
|
_resp = _req.get(
|
||||||
|
"http://localhost:3000/api/v1/repos/teleo/teleo-codex/pulls?state=open&limit=50",
|
||||||
|
headers={"Authorization": f"token {_token}"} if _token else {},
|
||||||
|
timeout=10,
|
||||||
|
)
|
||||||
|
if _resp.status_code == 200:
|
||||||
|
_prs = _resp.json()
|
||||||
|
forgejo_open = len(_prs)
|
||||||
|
forgejo_unmergeable = sum(1 for p in _prs if not p.get("mergeable", True))
|
||||||
|
except Exception:
|
||||||
|
# Fallback to DB counts if Forgejo unreachable
|
||||||
|
forgejo_open = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='open'").fetchone()["n"]
|
||||||
|
|
||||||
|
open_prs = forgejo_open
|
||||||
|
conflict_prs = forgejo_unmergeable
|
||||||
conflict_permanent_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='conflict_permanent'").fetchone()["n"]
|
conflict_permanent_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='conflict_permanent'").fetchone()["n"]
|
||||||
approved_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='approved'").fetchone()["n"]
|
approved_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='approved'").fetchone()["n"]
|
||||||
reviewing_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='reviewing'").fetchone()["n"]
|
reviewing_prs = conn.execute("SELECT COUNT(*) as n FROM prs WHERE status='reviewing'").fetchone()["n"]
|
||||||
backlog = open_prs + approved_prs + conflict_prs + reviewing_prs
|
backlog = open_prs
|
||||||
|
|
||||||
oldest_open = conn.execute(
|
oldest_open = conn.execute(
|
||||||
"SELECT MIN(created_at) as oldest FROM prs WHERE status='open'"
|
"SELECT MIN(created_at) as oldest FROM prs WHERE status='open'"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue