Fix some bugginess with how expired alerts and alert max_duration were handled. Closes #34

This commit is contained in:
Ian Renton
2025-10-08 16:09:39 +01:00
parent d7f9c36b28
commit e01b6d5ea9
7 changed files with 35 additions and 23 deletions

View File

@@ -34,13 +34,10 @@ class CleanupTimer:
self.alerts.expire()
# Alerts can persist in the system for a while, so we want to explicitly clean up any alerts that have
# definitively ended, or if they have no definite end time, then if the start time was more than 24 hours
# ago.
# expired
for id in list(self.alerts.iterkeys()):
alert = self.alerts[id]
if (alert.end_time and alert.end_time < datetime.now(pytz.UTC).timestamp()) or (
not alert.end_time and alert.start_time < (datetime.now(
pytz.UTC) - timedelta(days=1)).timestamp()):
if alert.expired():
self.alerts.evict(id)
self.status = "OK"