fix: evict oldest chart runs as a group instead of individual pings
This commit is contained in:
parent
993e6bb1df
commit
766d1094ad
|
|
@ -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();
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue