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(); });