Send the portal the failure count its own tile shows
The portal card's "Failures 24h" had read 0 since failures_24h left HealthSummary: that commit noted nothing read the field, which was true of this repo and not of the portal in index/, where health is an opaque JSON blob with no schema to catch the removal. Restored on the connector rather than in /summary — no screen here reads it, and it is folded from /observability/flows?hours=24, the same endpoint and window the app's Home tile sums, so the two cannot drift apart again. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ZeGnqVsf5VHQqvz4HdUhN
This commit is contained in:
@@ -255,18 +255,31 @@ class CloudConnector:
|
||||
Fetched through the same in-process transport as everything else, with
|
||||
a short-lived local token: the observability API is authenticated, and
|
||||
this process is entitled to mint one for the enrolling user.
|
||||
|
||||
``failures_24h`` is added here rather than by ``/summary``: it is the
|
||||
portal's tile and nothing on this installation reads it, and summing
|
||||
the same rollups over the same window the app's own Home tile sums
|
||||
keeps the two from drifting apart the way they already did once.
|
||||
"""
|
||||
from fluksio.core import security
|
||||
|
||||
token = security.create_access_token(config.local_user_id, timedelta(minutes=5))
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
try:
|
||||
async with self._client() as client:
|
||||
response = await client.get(
|
||||
"/api/v1/observability/summary",
|
||||
headers={"Authorization": f"Bearer {token}"},
|
||||
"/api/v1/observability/summary", headers=headers
|
||||
)
|
||||
if response.status_code == 200:
|
||||
if response.status_code != 200:
|
||||
return None
|
||||
summary: dict[str, Any] = response.json()
|
||||
rollups = await client.get(
|
||||
"/api/v1/observability/flows",
|
||||
params={"hours": 24},
|
||||
headers=headers,
|
||||
)
|
||||
if rollups.status_code == 200:
|
||||
summary["failures_24h"] = sum(row["errors"] for row in rollups.json())
|
||||
return summary
|
||||
except Exception:
|
||||
logger.debug("Could not collect a health summary for the portal")
|
||||
|
||||
Reference in New Issue
Block a user