feat(awooop): surface status chain on work queues
This commit is contained in:
@@ -1148,6 +1148,34 @@ async def _fetch_awooop_status_chain(
|
||||
)
|
||||
|
||||
|
||||
async def get_awooop_status_chain(
|
||||
*,
|
||||
project_id: str | None,
|
||||
incident_ids: list[str],
|
||||
) -> dict[str, Any]:
|
||||
"""Return the shared AwoooP status chain for UI surfaces without writing state."""
|
||||
normalized_incident_ids: list[str] = []
|
||||
for incident_id in incident_ids:
|
||||
safe_incident_id = str(incident_id or "").strip()
|
||||
if not safe_incident_id:
|
||||
continue
|
||||
_validate_incident_id_filter(safe_incident_id)
|
||||
_append_unique(normalized_incident_ids, safe_incident_id)
|
||||
|
||||
if not normalized_incident_ids:
|
||||
return _build_awooop_status_chain(incident_ids=[], source_id=None)
|
||||
|
||||
remediation_history = await _fetch_run_remediation_history(
|
||||
normalized_incident_ids,
|
||||
limit=5,
|
||||
)
|
||||
return await _fetch_awooop_status_chain(
|
||||
incident_ids=normalized_incident_ids,
|
||||
project_id=project_id or "awoooi",
|
||||
remediation_history=remediation_history,
|
||||
)
|
||||
|
||||
|
||||
def _validate_remediation_status_filter(value: str | None) -> None:
|
||||
if value is None:
|
||||
return
|
||||
@@ -1913,17 +1941,34 @@ async def list_approvals(
|
||||
]
|
||||
total = len(rows)
|
||||
|
||||
items = [
|
||||
{
|
||||
status_chain_cache: dict[tuple[str, tuple[str, ...]], dict[str, Any]] = {}
|
||||
items = []
|
||||
for r in rows:
|
||||
summary = remediation_summaries.get(r.run_id)
|
||||
summary_incident_ids = summary.get("incident_ids") if isinstance(summary, dict) else []
|
||||
incident_ids = [
|
||||
str(incident_id)
|
||||
for incident_id in summary_incident_ids
|
||||
if isinstance(incident_id, str) and incident_id
|
||||
]
|
||||
cache_key = (r.project_id, tuple(incident_ids))
|
||||
status_chain = status_chain_cache.get(cache_key)
|
||||
if status_chain is None:
|
||||
status_chain = await get_awooop_status_chain(
|
||||
project_id=r.project_id,
|
||||
incident_ids=incident_ids,
|
||||
)
|
||||
status_chain_cache[cache_key] = status_chain
|
||||
|
||||
items.append({
|
||||
"run_id": r.run_id,
|
||||
"project_id": r.project_id,
|
||||
"agent_id": r.agent_id,
|
||||
"created_at": r.created_at,
|
||||
"timeout_at": r.timeout_at,
|
||||
"remediation_summary": remediation_summaries.get(r.run_id),
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
"remediation_summary": summary,
|
||||
"awooop_status_chain": status_chain,
|
||||
})
|
||||
return {"approvals": items, "total": total, "items": items}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user