fix(awooop): sort mixed run timeline timestamps
All checks were successful
Code Review / ai-code-review (push) Successful in 10s
CD Pipeline / tests (push) Successful in 1m2s
CD Pipeline / build-and-deploy (push) Successful in 3m25s
CD Pipeline / post-deploy-checks (push) Successful in 1m18s

This commit is contained in:
Your Name
2026-05-15 03:29:55 +08:00
parent 1db4ef093c
commit 226f551e77
2 changed files with 31 additions and 1 deletions

View File

@@ -341,6 +341,14 @@ def _remediation_timeline_summary(item: dict[str, Any]) -> str:
)[:500]
def _timeline_sort_key(item: dict[str, Any], fallback_ts: Any) -> str:
"""Normalize mixed DB datetime / ISO string timestamps for timeline sorting."""
value = item.get("ts") or fallback_ts
if hasattr(value, "isoformat"):
return value.isoformat()
return str(value or "")
def _summarize_run_remediation_by_work_item(
items: list[dict[str, Any]],
) -> list[dict[str, Any]]:
@@ -700,7 +708,7 @@ async def get_run_detail(
timeline = sorted(
timeline,
key=lambda item: item["ts"] or run.created_at,
key=lambda item: _timeline_sort_key(item, run.created_at),
)[:_MAX_TIMELINE_ITEMS]
return {