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

@@ -35,11 +35,8 @@ class AlertProvider:
for alert in alerts:
# Fill in any blanks
alert.infer_missing()
# Add to the list, provided it meets the semsible date test. If alerts have an end time, it must be in the
# future, or if not, then the start date must be at least in the last 24 hours.
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()):
# Add to the list, provided it heas not already expired.
if not alert.expired():
self.alerts.add(alert.id, alert, expire=MAX_ALERT_AGE)
# Stop any threads and prepare for application shutdown