mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 16:59:25 +00:00
Fix some bugginess with how expired alerts and alert max_duration were handled. Closes #34
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user