fix: declare static agent routes before dynamic id route
This commit is contained in:
@@ -117,13 +117,19 @@ def _attention_item(item, problem, timestamp, *, rank, link=None, now=None):
|
||||
|
||||
|
||||
def installation_view(installation, agent, tenant, snapshot=None, *, now=None):
|
||||
has_snapshot = snapshot is not None
|
||||
snapshot = snapshot or AgentSnapshot(installation_id=installation.id)
|
||||
health, reason = compute_agent_health(installation, now=now, supplemental=snapshot)
|
||||
version_drift = snapshot.version_drift
|
||||
if version_drift == "UNKNOWN":
|
||||
if not version_drift or version_drift == "UNKNOWN":
|
||||
version_drift = compute_version_drift(agent.agent_version)
|
||||
fiscal_status = _fiscal_status(snapshot)
|
||||
coverage_partition = _coverage_partition(snapshot)
|
||||
if not has_snapshot:
|
||||
# No heartbeat/snapshot yet (e.g. an enrollment-only E2E row): expose
|
||||
# no counts at all rather than fabricated zeros — the UI shows
|
||||
# "Não informado" instead of None/0.
|
||||
coverage_partition = {"unclassified_products": None, "coverage_overcount_products": 0, "coverage_invalid_counts": False, "coverage_invariant_pass": True}
|
||||
version_drift_label = {"CURRENT": "Atualizada", "OUTDATED": "Desatualizada", "UNKNOWN": "Desconhecida"}.get(version_drift, str(version_drift))
|
||||
agent_version_display = f"{agent.agent_version} · {version_drift_label}" if agent.agent_version else "Desconhecida"
|
||||
return {
|
||||
@@ -153,15 +159,15 @@ def installation_view(installation, agent, tenant, snapshot=None, *, now=None):
|
||||
"last_seen_age": format_age(installation.last_seen_at, now),
|
||||
"started_at": _iso(installation.started_at),
|
||||
"last_status": installation.last_status,
|
||||
"total_products": snapshot.total_products,
|
||||
"fiscally_complete": snapshot.fiscally_complete,
|
||||
"safe_blocked": snapshot.safe_blocked,
|
||||
"failed_products": snapshot.failed_products,
|
||||
"total_products": snapshot.total_products if has_snapshot else None,
|
||||
"fiscally_complete": snapshot.fiscally_complete if has_snapshot else None,
|
||||
"safe_blocked": snapshot.safe_blocked if has_snapshot else None,
|
||||
"failed_products": snapshot.failed_products if has_snapshot else None,
|
||||
**coverage_partition,
|
||||
"coverage_percent": snapshot.coverage_percent,
|
||||
"fiscal_completion_percent": _fiscal_completion(snapshot),
|
||||
"fiscal_status": fiscal_status,
|
||||
"fiscal_status_label": fiscal_status.title(),
|
||||
"coverage_percent": snapshot.coverage_percent if has_snapshot else None,
|
||||
"fiscal_completion_percent": _fiscal_completion(snapshot) if has_snapshot else None,
|
||||
"fiscal_status": fiscal_status if has_snapshot else "UNKNOWN",
|
||||
"fiscal_status_label": fiscal_status.title() if has_snapshot else "Não informado",
|
||||
"blockers": snapshot.blockers or {},
|
||||
"last_job_status": snapshot.last_job_status,
|
||||
"last_job_at": _iso(snapshot.last_job_at),
|
||||
|
||||
Reference in New Issue
Block a user