Merge pull request #1734 from alphagov/count-letters-performance-platform

Send count of sent letters to performance platform
This commit is contained in:
Chris Hill-Scott
2018-03-05 14:51:47 +00:00
committed by GitHub
3 changed files with 16 additions and 1 deletions

View File

@@ -221,6 +221,7 @@ def send_total_sent_notifications_to_performance_platform():
count_dict = total_sent_notifications.get_total_sent_notifications_yesterday()
email_sent_count = count_dict.get('email').get('count')
sms_sent_count = count_dict.get('sms').get('count')
letter_sent_count = count_dict.get('letter').get('count')
start_date = count_dict.get('start_date')
current_app.logger.info(
@@ -240,6 +241,12 @@ def send_total_sent_notifications_to_performance_platform():
email_sent_count
)
total_sent_notifications.send_total_notifications_sent_for_day_stats(
start_date,
'letter',
letter_sent_count
)
@notify_celery.task(name='switch-current-sms-provider-on-slow-delivery')
@statsd(namespace="tasks")

View File

@@ -27,6 +27,7 @@ def get_total_sent_notifications_yesterday():
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')
letter_count = get_total_sent_notifications_in_date_range(start_date, end_date, 'letter')
return {
"start_date": start_date,
@@ -35,5 +36,8 @@ def get_total_sent_notifications_yesterday():
},
"sms": {
"count": sms_count
}
},
"letter": {
"count": letter_count
},
}

View File

@@ -56,6 +56,7 @@ def test_get_total_sent_notifications_yesterday_returns_expected_totals_dict(
# Create some notifications for the day before
yesterday = datetime(2016, 1, 10, 15, 30, 0, 0)
with freeze_time(yesterday):
notification_history(notification_type='letter')
notification_history(notification_type='sms')
notification_history(notification_type='sms')
notification_history(notification_type='email')
@@ -71,5 +72,8 @@ def test_get_total_sent_notifications_yesterday_returns_expected_totals_dict(
},
"sms": {
"count": 2
},
"letter": {
"count": 1
}
}