From 766d1094ad44b04c230e7f2504062323ea29135e Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 18 Mar 2026 20:00:11 +0400 Subject: [PATCH] fix: evict oldest chart runs as a group instead of individual pings --- apps/web/src/views/detail.ejs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/web/src/views/detail.ejs b/apps/web/src/views/detail.ejs index 6e75bef..a251d03 100644 --- a/apps/web/src/views/detail.ejs +++ b/apps/web/src/views/detail.ejs @@ -465,13 +465,23 @@ while (tbody.children.length > 100) tbody.removeChild(tbody.lastChild); } - // Chart — push new ping and re-render locally + // Chart — push new ping, evict oldest complete runs to cap at ~50 runs chartPings.push({ latency_ms: ping.latency_ms, region: ping.region || '__none__', checked_at: ping.checked_at, up: ping.up, run_id: ping.run_id || null, status_code: ping.status_code }); - if (chartPings.length > 200) chartPings.shift(); + // Count distinct runs and remove oldest runs as a group + const MAX_RUNS = 50; + const seen = []; const runSet = new Set(); + for (const p of chartPings) { + const rid = p.run_id || p.checked_at; + if (!runSet.has(rid)) { runSet.add(rid); seen.push(rid); } + } + if (seen.length > MAX_RUNS) { + const stale = new Set(seen.slice(0, seen.length - MAX_RUNS)); + chartPings = chartPings.filter(p => !stale.has(p.run_id || p.checked_at)); + } renderChart(); });