Add todo_md_staleness State Hub context resolver
Supports daily TODO.md stale-review ActivityDefinition via GET /repos/todo-md-staleness.
This commit is contained in:
parent
20f8b2f31f
commit
00917696dd
2 changed files with 71 additions and 0 deletions
|
|
@ -100,6 +100,8 @@ class StateHubContextResolver(ContextResolver):
|
|||
return _fetch_json(f"/state/domain/{domain}")
|
||||
if query == "repo_sbom_status":
|
||||
return _repo_sbom_status(params)
|
||||
if query == "todo_md_staleness":
|
||||
return _todo_md_staleness(params)
|
||||
if query == "state_summary":
|
||||
return _fetch_json("/state/summary")
|
||||
if query == "next_steps":
|
||||
|
|
@ -374,6 +376,26 @@ def _repo_sbom_status(params: dict[str, Any]) -> dict[str, Any]:
|
|||
return {}
|
||||
|
||||
|
||||
def _todo_md_staleness(params: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Resolve TODO.md staleness from State Hub.
|
||||
|
||||
Bulk mode (default): GET /repos/todo-md-staleness?stale_days=N
|
||||
Returns stale repos under `repos` plus summary fields for rule matching.
|
||||
"""
|
||||
stale_days = params.get("stale_days", 6)
|
||||
try:
|
||||
stale_days = int(stale_days)
|
||||
except (TypeError, ValueError):
|
||||
stale_days = 6
|
||||
payload = _fetch_json("/repos/todo-md-staleness", {"stale_days": stale_days})
|
||||
if not isinstance(payload, dict) or not payload:
|
||||
return {}
|
||||
repos = payload.get("repos")
|
||||
if not isinstance(repos, list):
|
||||
return {}
|
||||
return payload
|
||||
|
||||
|
||||
def _sbom_status_entry(repo_slug: str, last_sbom_at: Any) -> dict[str, Any]:
|
||||
age_days, has_sbom, normalised = _sbom_age_days(last_sbom_at)
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue