fix: outage indicator

This commit is contained in:
nate 2026-04-09 20:30:22 +04:00
parent 7bc3f920f3
commit 26be492dc7
1 changed files with 11 additions and 5 deletions

View File

@ -59,17 +59,23 @@
// Paused monitors are operator-declared maintenance — they don't count
// toward "down" or "degraded", but we surface a small note in the banner
// when at least one is in maintenance so visitors aren't confused.
let overall = 'up';
let paused_count = 0;
let down_count = 0;
let active_count = 0;
let has_degraded = false;
for (const m of monitors) {
if (m.current_state === 'paused') { paused_count++; continue; }
active_count++;
const partial = m.region_states.some(r => r.state === 'down') && m.region_states.some(r => r.state === 'up');
if (m.current_state === 'down') { overall = 'down'; break; }
if (partial && overall !== 'down') overall = 'degraded';
if (m.current_state === 'down') down_count++;
else if (partial) has_degraded = true;
}
const overall = down_count === 0 && !has_degraded ? 'up'
: active_count > 0 && down_count === active_count ? 'down'
: 'degraded';
let overallText = overall === 'up' ? 'All systems operational'
: overall === 'degraded' ? 'Some systems degraded'
: 'Major outage in progress';
: overall === 'down' ? 'Major outage in progress'
: 'Partial outage';
if (paused_count > 0) {
overallText += ' — ' + paused_count + (paused_count === 1 ? ' service' : ' services') + ' under maintenance';
}