mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
Created a task to update ft_notification_status for the last three days.
This commit is contained in:
@@ -8,6 +8,7 @@ from app.dao.fact_billing_dao import (
|
||||
fetch_billing_data_for_day,
|
||||
update_fact_billing
|
||||
)
|
||||
from app.dao.fact_notification_status_dao import fetch_notification_status_for_day, update_fact_notification_status
|
||||
|
||||
|
||||
@notify_celery.task(name="create-nightly-billing")
|
||||
@@ -30,3 +31,24 @@ def create_nightly_billing(day_start=None):
|
||||
|
||||
current_app.logger.info(
|
||||
"create-nightly-billing task complete. {} rows updated for day: {}".format(len(transit_data), process_day))
|
||||
|
||||
|
||||
@notify_celery.task(name="create-nightly-notification-status")
|
||||
@statsd(namespace="tasks")
|
||||
def create_nightly_notification_status(day_start=None):
|
||||
# day_start is a datetime.date() object. e.g.
|
||||
# 3 days of data counting back from day_start is consolidated
|
||||
if day_start is None:
|
||||
day_start = datetime.today() - timedelta(days=1)
|
||||
else:
|
||||
# When calling the task its a string in the format of "YYYY-MM-DD"
|
||||
day_start = datetime.strptime(day_start, "%Y-%m-%d")
|
||||
for i in range(0, 3):
|
||||
process_day = day_start - timedelta(days=i)
|
||||
|
||||
transit_data = fetch_notification_status_for_day(process_day=process_day)
|
||||
|
||||
update_fact_notification_status(transit_data, process_day)
|
||||
|
||||
current_app.logger.info(
|
||||
"create-nightly-notification-status task: {} rows updated for day: {}")
|
||||
|
||||
Reference in New Issue
Block a user