From 90d9135fcfbfe2a974d6aaedd4f2cdd114f4edb3 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Thu, 22 Nov 2018 15:17:17 +0000 Subject: [PATCH] Return cancelled letters for dashboard Added cancelled letters to the number of failed letters in the statistics that get used for the dashboard. At some point, we want to stop including cancelled letters in the stats, but for now this keeps things consistent with our current letter failure state, permanent-failure. --- app/models.py | 1 + app/service/statistics.py | 2 +- tests/app/service/test_statistics.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models.py b/app/models.py index 7accfc7c5..93a9bcd0c 100644 --- a/app/models.py +++ b/app/models.py @@ -1135,6 +1135,7 @@ NOTIFICATION_STATUS_TYPES_COMPLETED = [ NOTIFICATION_TEMPORARY_FAILURE, NOTIFICATION_PERMANENT_FAILURE, NOTIFICATION_RETURNED_LETTER, + NOTIFICATION_CANCELLED, ] NOTIFICATION_STATUS_SUCCESS = [ diff --git a/app/service/statistics.py b/app/service/statistics.py index 3d22b20d6..e1ed57aeb 100644 --- a/app/service/statistics.py +++ b/app/service/statistics.py @@ -86,7 +86,7 @@ def _update_statuses_from_row(update_dict, row): update_dict['delivered'] += row.count elif row.status in ( 'failed', 'technical-failure', 'temporary-failure', - 'permanent-failure', 'validation-failed', 'virus-scan-failed'): + 'permanent-failure', 'validation-failed', 'virus-scan-failed', 'cancelled'): update_dict['failed'] += row.count diff --git a/tests/app/service/test_statistics.py b/tests/app/service/test_statistics.py index 715553359..6ba357d3b 100644 --- a/tests/app/service/test_statistics.py +++ b/tests/app/service/test_statistics.py @@ -38,7 +38,8 @@ NewStatsRow = collections.namedtuple('row', ('notification_type', 'status', 'key StatsRow('letter', 'validation-failed', 1), StatsRow('letter', 'virus-scan-failed', 1), StatsRow('letter', 'permanent-failure', 1), - ], [4, 0, 4], [0, 0, 0], [3, 0, 3]), + StatsRow('letter', 'cancelled', 1), + ], [4, 0, 4], [0, 0, 0], [4, 0, 4]), 'convert_sent_to_delivered': ([ StatsRow('sms', 'sending', 1), StatsRow('sms', 'delivered', 1),