Skip to content

Commit e49c11c

Browse files
committed
align dashboard API responses with REACT frontent expectations
1 parent f4c50b1 commit e49c11c

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

apiforgepy/dashboard.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,9 @@
324324
<body>
325325
<div id="root"></div>
326326
327-
<!-- React UMD served from node_modules by apiforgejs dashboard server -->
328-
<script src="/assets/react.js"></script>
329-
<script src="/assets/react-dom.js"></script>
330-
<!-- Babel standalone for in-browser JSX transpilation -->
331-
<script src="https://unpkg.com/@babel/standalone@7/babel.min.js" crossorigin></script>
327+
<script src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js" crossorigin></script>
328+
<script src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>
329+
<script src="https://cdn.jsdelivr.net/npm/@babel/standalone@7/babel.min.js" crossorigin></script>
332330
333331
<script type="text/babel" data-presets="react">
334332
'use strict';
@@ -1673,9 +1671,23 @@ def do_GET(self):
16731671
if path == "/" or path == "":
16741672
self._respond(200, "text/html", _HTML.encode())
16751673
elif path == "/api/summary":
1676-
summary = db.get_summary()
1677-
summary["health_score"] = compute_health_score(db)
1678-
self._json(summary)
1674+
raw = db.get_summary()
1675+
recent = raw.get("recent") or {}
1676+
total = recent.get("calls_total") or 0
1677+
errors = (recent.get("calls_4xx") or 0) + (recent.get("calls_5xx") or 0)
1678+
err_rate = round((errors / total) * 100, 2) if total > 0 else 0.0
1679+
insights = get_insights(db)
1680+
self._json({
1681+
"health_score": compute_health_score(db),
1682+
"calls_24h": total,
1683+
"error_rate_24h": err_rate,
1684+
"avg_p90_24h": round(recent.get("avg_p90") or 0, 2),
1685+
"avg_p99_24h": round(recent.get("avg_p99") or 0, 2),
1686+
"active_routes": raw.get("active_routes", 0),
1687+
"total_routes": raw.get("total_routes", 0),
1688+
"insights_count": len(insights),
1689+
"insights": insights,
1690+
})
16791691
elif path == "/api/routes":
16801692
hours = int(qs.get("hours", [24])[0])
16811693
self._json(db.get_routes(hours))
@@ -1687,6 +1699,11 @@ def do_GET(self):
16871699
self._json(db.get_time_series(route, method, hours))
16881700
else:
16891701
self._json(db.get_global_time_series(hours))
1702+
elif path == "/api/global-timeseries":
1703+
hours = int(qs.get("hours", [24])[0])
1704+
self._json(db.get_global_time_series(hours))
1705+
elif path == "/api/releases":
1706+
self._json(db.get_releases() if hasattr(db, "get_releases") else [])
16901707
elif path == "/api/insights":
16911708
self._json(get_insights(db))
16921709
else:

0 commit comments

Comments
 (0)