fix: avgLatency NaN — extract .latency_ms from ping objects

This commit is contained in:
M1 2026-03-18 16:31:08 +04:00
parent 07648672ad
commit e057a65535
1 changed files with 2 additions and 1 deletions

View File

@ -25,7 +25,8 @@
<% } else { %>
<% it.monitors.forEach(function(m) {
const latencies = (m.pings || []).filter(p => p.latency_ms != null);
const avgLatency = latencies.length ? Math.round(latencies.reduce((a, b) => a + b, 0) / latencies.length) : null;
const latencyVals = latencies.map(p => p.latency_ms);
const avgLatency = latencyVals.length ? Math.round(latencyVals.reduce((a, b) => a + b, 0) / latencyVals.length) : null;
%>
<a href="/dashboard/monitors/<%= m.id %>" data-monitor-id="<%= m.id %>" class="block bg-gray-900 hover:bg-gray-800/80 border border-gray-800 rounded-xl p-4 transition-colors group">
<div class="flex items-center justify-between">