From d41d3a37376217f837918babe60b90d735d0e3b9 Mon Sep 17 00:00:00 2001 From: M1 Date: Mon, 16 Mar 2026 17:13:48 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20latency=20chart=20red=20dots=20=E2=80=94?= =?UTF-8?q?=20track=20up/down=20with=20latency=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/views/detail.ejs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/web/src/views/detail.ejs b/apps/web/src/views/detail.ejs index f29bdbd..f2f09d4 100644 --- a/apps/web/src/views/detail.ejs +++ b/apps/web/src/views/detail.ejs @@ -224,7 +224,7 @@ // Seed running stats for SSE incremental updates _totalPings = results.length; _upPings = upPings.length; - _latencies = latencies.slice(-100); + _latencies = results.filter(r => r.latency_ms != null).slice(-100).map(r => ({ ms: r.latency_ms, up: r.up })); document.getElementById('stat-status').innerHTML = lastPing ? (lastPing.up ? 'Up' : 'Down') @@ -361,7 +361,7 @@ // No interval poll — SSE handles all live updates // Track running stats in memory for incremental updates - let _totalPings = 0, _upPings = 0, _latencies = []; + let _totalPings = 0, _upPings = 0, _latencies = []; // _latencies: [{ms, up}] // SSE: live ping updates const id = window.location.pathname.split('/').pop(); @@ -370,9 +370,9 @@ _totalPings++; if (ping.up) _upPings++; if (ping.latency_ms != null) { - _latencies.push(ping.latency_ms); + _latencies.push({ ms: ping.latency_ms, up: ping.up }); if (_latencies.length > 100) _latencies.shift(); - const avg = Math.round(_latencies.reduce((a,b)=>a+b,0) / _latencies.length); + const avg = Math.round(_latencies.reduce((a,b)=>a+b.ms,0) / _latencies.length); document.getElementById('stat-latency').textContent = avg + 'ms'; } @@ -398,9 +398,7 @@ // ── Latency chart ───────────────────────────────────────────── if (ping.latency_ms != null) { - renderLatencyChart([...(_latencies.map((ms, i) => ({ - latency_ms: ms, checked_at: new Date(Date.now() - (_latencies.length - i) * 10000).toISOString() - })))]); + renderLatencyChart(_latencies.map(e => ({ latency_ms: e.ms, up: e.up, checked_at: '' }))); } // ── Ping table ───────────────────────────────────────────────