fix(awooop): sort mixed run timeline timestamps
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user