diff --git a/apps/web/src/views/home.ejs b/apps/web/src/views/home.ejs index bd933ff..3a3f6eb 100644 --- a/apps/web/src/views/home.ejs +++ b/apps/web/src/views/home.ejs @@ -53,9 +53,15 @@ const downCount = monitorsWithPings.filter(m => m.pings[0]?.up === false).length; summary.innerHTML = `${upCount} up · ${downCount} down · ${monitors.length} total`; + // Store latencies per monitor for live sparkline updates + window._monitorLatencies = window._monitorLatencies || {}; + monitorsWithPings.forEach(m => { + window._monitorLatencies[m.id] = m.pings.filter(c => c.latency_ms != null).map(c => c.latency_ms).reverse(); + }); + list.innerHTML = monitorsWithPings.map(m => { const lastPing = m.pings[0]; - const latencies = m.pings.filter(c => c.latency_ms != null).map(c => c.latency_ms).reverse(); + const latencies = window._monitorLatencies[m.id]; const avgLatency = latencies.length ? Math.round(latencies.reduce((a, b) => a + b, 0) / latencies.length) : null; return ` @@ -69,7 +75,7 @@