fix: report total counts in wf status

This commit is contained in:
lda
2026-06-09 20:42:00 +07:00 Verified
parent efe80effbc
commit 0f16f7990e
2 changed files with 25 additions and 3 deletions
+12 -3
View File
@@ -42,7 +42,7 @@ async def _fetch_status_data(context: CliContext) -> dict[str, Any]:
if isinstance(item, dict) and isinstance(item.get("name"), str)
]
workflow = {
"capability_count": len(items),
"capability_count": _payload_count(capabilities, "capabilities"),
"sample_capabilities": names[:5],
}
@@ -72,7 +72,7 @@ async def _fetch_sources(context: CliContext) -> dict[str, Any]:
]
return {
"available": True,
"source_count": len(sources),
"source_count": _payload_count(payload, "sources"),
"sample_sources": source_ids[:5],
}
@@ -112,10 +112,19 @@ async def _fetch_registry(context: CliContext) -> dict[str, Any]:
return _unavailable(exc)
return {
"available": True,
"entry_count": len(payload.get("entries", [])),
"entry_count": _payload_count(payload, "entries"),
}
def _payload_count(payload: dict[str, Any], items_key: str) -> int:
"""Prefer a paged API's total count, falling back to the current page size."""
total = payload.get("total")
if isinstance(total, int):
return total
items = payload.get(items_key, [])
return len(items) if isinstance(items, list) else 0
def _unavailable(exc: Exception) -> dict[str, Any]:
return {
"available": False,