Skip to content

Commit

Permalink
Don't replay alerts on startup, only last 15 minutes. #588
Browse files Browse the repository at this point in the history
  • Loading branch information
guydavis committed Mar 9, 2022
1 parent 170110c commit 8ba7660
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions api/schedules/status_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,15 @@
from api.commands import chiadog_cli
from api import app, utils

first_run = True

def update():
global first_run
if globals.load()['is_controller']:
#app.logger.info("Skipping alerts polling on fullnode are already placed in database directly via chiadog_notifier.sh script.")
return
with app.app_context():
try:
from api import db
hostname = utils.get_hostname()
if first_run: # On first launch, load last week of notifications
since = (datetime.datetime.now() - datetime.timedelta(weeks=1)).strftime("%Y-%m-%d %H:%M:%S")
first_run = False
else: # On subsequent schedules, load only last 15 minutes.
since = (datetime.datetime.now() - datetime.timedelta(minutes=15)).strftime("%Y-%m-%d %H:%M:%S")
since = (datetime.datetime.now() - datetime.timedelta(minutes=15)).strftime("%Y-%m-%d %H:%M:%S")
alerts = db.session.query(a.Alert).filter(a.Alert.created_at >= since).order_by(a.Alert.created_at.desc()).limit(20).all()
payload = []
for alert in alerts:
Expand Down

0 comments on commit 8ba7660

Please sign in to comment.