Add command to backfill Performance Platform totals

We don’t have any way of playing back the totals we send to performance
platform.

This commit copies the command used to backfill the processing time and
adapts it to backfill the totals instead. Under the hood it uses the
same code that we use in the scheduled tasks to update performance
platform on a daily basis. I had to modify this code to take a `day`
argument because it was hardcoded to only work for ‘yesterday’.
This commit is contained in:
Chris Hill-Scott
2018-03-05 16:44:20 +00:00
parent 98d5408d7d
commit ca167206d5
6 changed files with 64 additions and 20 deletions

View File

@@ -1,11 +1,8 @@
from datetime import datetime
from datetime import timedelta
from app import performance_platform_client
from app.dao.notifications_dao import get_total_sent_notifications_in_date_range
from app.utils import (
get_london_midnight_in_utc,
get_midnight_for_day_before
)
from app.utils import get_london_midnight_in_utc
def send_total_notifications_sent_for_day_stats(date, notification_type, count):
@@ -20,10 +17,9 @@ def send_total_notifications_sent_for_day_stats(date, notification_type, count):
performance_platform_client.send_stats_to_performance_platform(payload)
def get_total_sent_notifications_yesterday():
today = datetime.utcnow()
start_date = get_midnight_for_day_before(today)
end_date = get_london_midnight_in_utc(today)
def get_total_sent_notifications_for_day(day):
start_date = get_london_midnight_in_utc(day)
end_date = start_date + timedelta(days=1)
email_count = get_total_sent_notifications_in_date_range(start_date, end_date, 'email')
sms_count = get_total_sent_notifications_in_date_range(start_date, end_date, 'sms')