Merge pull request #932 from alphagov/service-stats

treat sent as delivered in detailed service api
This commit is contained in:
Imdad Ahad
2017-04-28 14:15:30 +01:00
committed by GitHub
3 changed files with 9 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ def create_zeroed_stats_dicts():
def _update_statuses_from_row(update_dict, row):
update_dict['requested'] += row.count
if row.status == 'delivered':
if row.status in ('delivered', 'sent'):
update_dict['delivered'] += row.count
elif row.status in ('failed', 'technical-failure', 'temporary-failure', 'permanent-failure'):
update_dict['failed'] += row.count

View File

@@ -43,6 +43,7 @@ def test_should_get_all_statuses_for_notifications_associated_with_job(
notification(status='technical-failure')
notification(status='temporary-failure')
notification(status='permanent-failure')
notification(status='sent')
results = dao_get_notification_outcomes_for_job(sample_service.id, sample_job.id)
assert [(row.count, row.status) for row in results] == [
@@ -53,7 +54,8 @@ def test_should_get_all_statuses_for_notifications_associated_with_job(
(1, 'failed'),
(1, 'technical-failure'),
(1, 'temporary-failure'),
(1, 'permanent-failure')
(1, 'permanent-failure'),
(1, 'sent')
]

View File

@@ -30,6 +30,11 @@ StatsRow = collections.namedtuple('row', ('notification_type', 'status', 'count'
StatsRow('email', 'temporary-failure', 1),
StatsRow('email', 'permanent-failure', 1),
], [4, 0, 4], [0, 0, 0], [0, 0, 0]),
'convert_sent_to_delivered': ([
StatsRow('sms', 'sending', 1),
StatsRow('sms', 'delivered', 1),
StatsRow('sms', 'sent', 1),
], [0, 0, 0], [3, 2, 0], [0, 0, 0]),
})
def test_format_statistics(stats, email_counts, sms_counts, letter_counts):