fix: outage indicator
This commit is contained in:
parent
7bc3f920f3
commit
26be492dc7
|
|
@ -59,17 +59,23 @@
|
||||||
// Paused monitors are operator-declared maintenance — they don't count
|
// Paused monitors are operator-declared maintenance — they don't count
|
||||||
// toward "down" or "degraded", but we surface a small note in the banner
|
// 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.
|
// when at least one is in maintenance so visitors aren't confused.
|
||||||
let overall = 'up';
|
|
||||||
let paused_count = 0;
|
let paused_count = 0;
|
||||||
|
let down_count = 0;
|
||||||
|
let active_count = 0;
|
||||||
|
let has_degraded = false;
|
||||||
for (const m of monitors) {
|
for (const m of monitors) {
|
||||||
if (m.current_state === 'paused') { paused_count++; continue; }
|
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');
|
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 (m.current_state === 'down') down_count++;
|
||||||
if (partial && overall !== 'down') overall = 'degraded';
|
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'
|
let overallText = overall === 'up' ? 'All systems operational'
|
||||||
: overall === 'degraded' ? 'Some systems degraded'
|
: overall === 'down' ? 'Major outage in progress'
|
||||||
: 'Major outage in progress';
|
: 'Partial outage';
|
||||||
if (paused_count > 0) {
|
if (paused_count > 0) {
|
||||||
overallText += ' — ' + paused_count + (paused_count === 1 ? ' service' : ' services') + ' under maintenance';
|
overallText += ' — ' + paused_count + (paused_count === 1 ? ' service' : ' services') + ' under maintenance';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue