fix: emit stats/histogram snapshot on SSE connect; remove polling api.get('/stats') from Dashboard

This commit is contained in:
2026-04-09 19:23:24 -04:00
parent d2a569496d
commit 6b8392102e
2 changed files with 11 additions and 25 deletions

View File

@@ -32,6 +32,15 @@ async def stream_events(
if last_id == 0:
last_id = await repo.get_max_log_id()
# Emit initial snapshot immediately so the client never needs to poll /stats
stats = await repo.get_stats_summary()
yield f"event: message\ndata: {json.dumps({'type': 'stats', 'data': stats})}\n\n"
histogram = await repo.get_log_histogram(
search=search, start_time=start_time,
end_time=end_time, interval_minutes=15,
)
yield f"event: message\ndata: {json.dumps({'type': 'histogram', 'data': histogram})}\n\n"
while True:
if await request.is_disconnected():
break