Files
patrickandClaude Sonnet 5.5 347f55cf7c
test / pytest (3.11) (push) Canceled after 0s
test / pytest (3.13) (push) Canceled after 0s
feat: Phase 6c baseline, ack, host alarms, outage notice, send limit, privacy mode, UI link
Includes atomic migrations, per-rule reminder semantics, first-run helper script
and the note on the undecided UI chat idea.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 03:06:23 +01:00

28 lines
1.2 KiB
Python

from typing import Iterable, Sequence
from ..models import KIND_PROBLEM, KIND_REMINDER, STATE_CRIT, Event, StateRow, ack_holds
from ..mutes import Mute, find_active_mute
from ..routing import Route, resolve_reminder_hours
SECONDS_PER_HOUR = 3600
def due_reminders(rows: Iterable[StateRow], rules: Sequence[Route], mutes: Sequence[Mute],
default_hours: int, now: int) -> list[Event]:
events = []
for row in rows:
if row.state != STATE_CRIT or row.reported_state != STATE_CRIT or row.in_downtime or row.flapping:
continue
if ack_holds(row.state, row.ack_state):
continue
if find_active_mute(mutes, row.host, row.service, now):
continue
probe = Event(now, row.host, row.service, KIND_PROBLEM, row.state, row.output)
hours = resolve_reminder_hours(rules, probe, default_hours)
if hours <= 0 or now - max(row.last_reminder_ts, row.reported_at) < hours * SECONDS_PER_HOUR:
continue
events.append(Event(now, row.host, row.service, KIND_REMINDER, row.state, row.output,
since_ts=row.last_state_change, problem_since_ts=row.problem_since))
return events