From 3ad00adfb32df00b03000d08bcf144b43bdb403f Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 6 Mar 2020 09:45:02 +0000 Subject: [PATCH] Reverse chronologically sort scheduled jobs Now that scheduled jobs are mixed in with regular jobs it looks weird for the sort order to be different. This makes the sort order consistently go from furthest in the future to furthest in the past. The old sort order made sense when scheduled jobs were displayed separately on the dashboard. --- app/notify_client/job_api_client.py | 3 ++- app/templates/views/dashboard/_upcoming.html | 2 +- tests/app/main/views/test_jobs.py | 8 ++++---- tests/app/main/views/test_uploads.py | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/notify_client/job_api_client.py b/app/notify_client/job_api_client.py index 81b7cfb12..803bbe26e 100644 --- a/app/notify_client/job_api_client.py +++ b/app/notify_client/job_api_client.py @@ -70,7 +70,8 @@ class JobApiClient(NotifyAdminAPIClient): service_id, statuses=[self.SCHEDULED_JOB_STATUS] )['data'], - key=lambda job: job['scheduled_for'] + key=lambda job: job['scheduled_for'], + reverse=True, ) @cache.set('has_jobs-{service_id}') diff --git a/app/templates/views/dashboard/_upcoming.html b/app/templates/views/dashboard/_upcoming.html index 85dbf4ce3..b0a179230 100644 --- a/app/templates/views/dashboard/_upcoming.html +++ b/app/templates/views/dashboard/_upcoming.html @@ -20,7 +20,7 @@ {% endif %} diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index c17a11a0f..c4ea99aab 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -44,14 +44,14 @@ from tests.conftest import ( ( 'File Messages to be sent' ), - ( - 'send_me_later.csv ' - 'Sending 1 January 2016 at 11:09am 1' - ), ( 'even_later.csv ' 'Sending 1 January 2016 at 11:09pm 1' ), + ( + 'send_me_later.csv ' + 'Sending 1 January 2016 at 11:09am 1' + ), ( 'File Status' ), diff --git a/tests/app/main/views/test_uploads.py b/tests/app/main/views/test_uploads.py index 943e5b205..b62753e77 100644 --- a/tests/app/main/views/test_uploads.py +++ b/tests/app/main/views/test_uploads.py @@ -668,13 +668,13 @@ def test_uploads_page_shows_scheduled_jobs( 'File Status' ), ( - 'send_me_later.csv ' - 'Sending 1 January 2016 at 11:09am ' + 'even_later.csv ' + 'Sending 1 January 2016 at 11:09pm ' '1 text message waiting to send' ), ( - 'even_later.csv ' - 'Sending 1 January 2016 at 11:09pm ' + 'send_me_later.csv ' + 'Sending 1 January 2016 at 11:09am ' '1 text message waiting to send' ), ]