mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Further alert implementation #17
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytz
|
||||
|
||||
@@ -35,8 +35,12 @@ class AlertProvider:
|
||||
for alert in alerts:
|
||||
# Fill in any blanks
|
||||
alert.infer_missing()
|
||||
# Add to the list
|
||||
self.alerts.add(alert.id, alert, expire=MAX_ALERT_AGE)
|
||||
# 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()):
|
||||
self.alerts.add(alert.id, alert, expire=MAX_ALERT_AGE)
|
||||
|
||||
# Stop any threads and prepare for application shutdown
|
||||
def stop(self):
|
||||
|
||||
Reference in New Issue
Block a user