mirror of
https://github.com/sartography/uva-covid19-testing-communicator.git
synced 2025-02-23 12:28:26 +00:00
throttle notifications so we don't run afoul of the email and text message servers.
This commit is contained in:
parent
2fe87b1cf9
commit
7b4cbe4c24
@ -4,6 +4,7 @@ from communicator.models.notification import Notification, EMAIL_TYPE, TEXT_TYPE
|
||||
from communicator.services.ivy_service import IvyService
|
||||
from communicator.services.notification_service import NotificationService
|
||||
from communicator.services.sample_service import SampleService
|
||||
from time import sleep
|
||||
|
||||
|
||||
def status():
|
||||
@ -53,6 +54,7 @@ def notify_by_email():
|
||||
except Exception as e:
|
||||
db.session.add(Notification(type=EMAIL_TYPE, sample=sample, successful=False,
|
||||
error_message=str(e)))
|
||||
sleep(0.5)
|
||||
|
||||
def notify_by_text():
|
||||
"""Sends out notifications via SMS Message, but only at reasonable times of day"""
|
||||
@ -73,6 +75,7 @@ def notify_by_text():
|
||||
except Exception as e:
|
||||
db.session.add(Notification(type=TEXT_TYPE, sample=sample, successful=False,
|
||||
error_message=str(e)))
|
||||
sleep(0.5)
|
||||
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ scheduler = BackgroundScheduler()
|
||||
scheduler.add_jobstore('sqlalchemy', url=db.engine.url)
|
||||
scheduler.add_job(
|
||||
update_and_notify, 'interval', minutes=app.config['SCHEDULED_TASK_MINUTES'],
|
||||
# update_and_notify, 'interval', seconds=5,
|
||||
id='update_data', replace_existing=True
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user