Include ‘created’ in ‘sending’ bucket

The difference between created and sending isn’t something a user should
have to care about. So this commit:
- counts created and sending as the same thing
- displays and notifications which have a status of created as sending
This commit is contained in:
Chris Hill-Scott
2016-08-03 09:47:12 +01:00
parent 51a4ab8060
commit 45ae43d987
3 changed files with 18 additions and 20 deletions

View File

@@ -243,7 +243,8 @@ def format_notification_status(status, template_type):
'temporary-failure': 'Inbox not accepting messages right now',
'permanent-failure': 'Email address doesnt exist',
'delivered': 'Delivered',
'sending': 'Sending'
'sending': 'Sending',
'created': 'Sending'
},
'sms': {
'failed': 'Failed',
@@ -251,7 +252,8 @@ def format_notification_status(status, template_type):
'temporary-failure': 'Phone not accepting messages right now',
'permanent-failure': 'Phone number doesnt exist',
'delivered': 'Delivered',
'sending': 'Sending'
'sending': 'Sending',
'created': 'Sending'
}
}.get(template_type).get(status, status)
@@ -263,7 +265,8 @@ def format_notification_status_as_field_status(status):
'temporary-failure': 'error',
'permanent-failure': 'error',
'delivered': None,
'sending': 'default'
'sending': 'default',
'created': 'default'
}.get(status, 'error')

View File

@@ -48,10 +48,11 @@ def _parse_filter_args(filter_dict):
def _set_status_filters(filter_args):
all_failure_statuses = ['failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
all_statuses = ['sending', 'delivered'] + all_failure_statuses
all_sending_statuses = ['created', 'sending']
all_statuses = all_sending_statuses + ['delivered'] + all_failure_statuses
if filter_args.get('status'):
if 'processed' in filter_args.get('status'):
filter_args['status'] = all_statuses
if 'sending' in filter_args.get('status'):
filter_args['status'].extend(all_sending_statuses[:1])
elif 'failed' in filter_args.get('status'):
filter_args['status'].extend(all_failure_statuses[1:])
else:
@@ -291,12 +292,10 @@ def _get_job_counts(job, help_argument):
job.get('notification_count', 0)
],
[
'Sending', 'sending',
(
job.get('notification_count', 0) -
job.get('notifications_delivered', 0) -
job.get('notifications_failed', 0)
)
'sending', 'sending',
job.get('notification_count', 0) -
job.get('notifications_delivered', 0) -
job.get('notifications_failed', 0)
],
[
'delivered', 'delivered',

View File

@@ -32,15 +32,11 @@ def test_should_return_list_of_all_jobs(app_,
"status_argument, expected_api_call", [
(
'',
['sending', 'delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
),
(
'processed',
['sending', 'delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
['created', 'sending', 'delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
),
(
'sending',
['sending']
['sending', 'created']
),
(
'delivered',
@@ -180,11 +176,11 @@ def test_should_show_updates_for_one_job_as_json(
"status_argument, expected_api_call", [
(
'',
['sending', 'delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
['created', 'sending', 'delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
),
(
'sending',
['sending']
['sending', 'created']
),
(
'delivered',