From 3d7f07493b303155929dd202ce08a94603ef1f8e Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 7 Jun 2016 12:01:43 +0100 Subject: [PATCH] =?UTF-8?q?Add=20filters=20for=20=E2=80=98processed?= =?UTF-8?q?=E2=80=99=20and=20sending=20states?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _Processed_ is all the notifications that we know about, ie sending, failed and delivered - _Sending_ is notifications that we have either put into a queue or are waiting to hear back from the provider about. The big numbers on the dashboard are a count of all the messages we’ve processed. So when you click them, the table of notifications you see on the dashboard should contain that number of notifications. This also gets the activity page one step closer to being like the job page: | Before | After ---------|----------------------------|--------------------------------- Activity | Sending, failed, both | Processed, sending, failed, delivered Job page | Sending, failed, delivered | Sending, failed, delivered --- app/main/views/jobs.py | 16 ++++++++++------ app/templates/views/dashboard/today.html | 4 ++-- tests/app/main/views/test_jobs.py | 12 ++++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index e87450863..194cb0563 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -43,12 +43,15 @@ 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 if filter_args.get('status'): - if 'failed' in filter_args.get('status'): - filter_args['status'].extend(['temporary-failure', 'permanent-failure', 'technical-failure']) + if 'processed' in filter_args.get('status'): + filter_args['status'] = all_statuses + elif 'failed' in filter_args.get('status'): + filter_args['status'].extend(all_failure_statuses[1:]) else: - # default to everything - filter_args['status'] = ['delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure'] + filter_args['status'] = all_statuses @main.route("/services//jobs") @@ -232,9 +235,10 @@ def view_notifications(service_id, message_type): message_type=message_type, status=item[1] )] for item in [ - ['Successful', 'delivered'], + ['Processed', 'sending,delivered,failed'], + ['Sending', 'sending'], + ['Delivered', 'delivered'], ['Failed', 'failed'], - ['', 'delivered,failed'] ] ] ) diff --git a/app/templates/views/dashboard/today.html b/app/templates/views/dashboard/today.html index cb50dd08f..d13cfe2bc 100644 --- a/app/templates/views/dashboard/today.html +++ b/app/templates/views/dashboard/today.html @@ -19,7 +19,7 @@ statistics.get('emails_failure_rate', 0.0), statistics.get('emails_failure_rate', 0)|float > 3, failure_link=url_for(".view_notifications", service_id=current_service.id, message_type='email', status='failed'), - label_link=url_for(".view_notifications", service_id=current_service.id, message_type='email', status='delivered,failed') + label_link=url_for(".view_notifications", service_id=current_service.id, message_type='email', status='sending,delivered,failed') ) }}
@@ -30,7 +30,7 @@ statistics.get('sms_failure_rate', 0.0), statistics.get('sms_failure_rate', 0)|float > 3, failure_link=url_for(".view_notifications", service_id=current_service.id, message_type='sms', status='failed'), - label_link=url_for(".view_notifications", service_id=current_service.id, message_type='sms', status='delivered,failed') + label_link=url_for(".view_notifications", service_id=current_service.id, message_type='sms', status='sending,delivered,failed') ) }}
diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 70123fb2d..473367424 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -87,6 +87,14 @@ def test_should_show_updates_for_one_job_as_json( ) @pytest.mark.parametrize( "status_argument, expected_api_call", [ + ( + 'processed', + ['sending', 'delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure'] + ), + ( + 'sending', + ['sending'] + ), ( 'delivered', ['delivered'] @@ -94,10 +102,6 @@ def test_should_show_updates_for_one_job_as_json( ( 'failed', ['failed', 'temporary-failure', 'permanent-failure', 'technical-failure'] - ), - ( - 'delivered,failed', - ['delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure'] ) ] )