diff --git a/app/notify_client/job_api_client.py b/app/notify_client/job_api_client.py index 7fa93d52f..803bbe26e 100644 --- a/app/notify_client/job_api_client.py +++ b/app/notify_client/job_api_client.py @@ -14,8 +14,9 @@ class JobApiClient(NotifyAdminAPIClient): 'ready to send', 'sent to dvla' } - - NON_SCHEDULED_JOB_STATUSES = JOB_STATUSES - {'scheduled', 'cancelled'} + SCHEDULED_JOB_STATUS = 'scheduled' + CANCELLED_JOB_STATUS = 'cancelled' + NON_SCHEDULED_JOB_STATUSES = JOB_STATUSES - {SCHEDULED_JOB_STATUS, CANCELLED_JOB_STATUS} def get_job(self, service_id, job_id): params = {} @@ -65,8 +66,12 @@ class JobApiClient(NotifyAdminAPIClient): def get_scheduled_jobs(self, service_id): return sorted( - self.get_jobs(service_id, statuses=['scheduled'])['data'], - key=lambda job: job['scheduled_for'] + self.get_jobs( + service_id, + statuses=[self.SCHEDULED_JOB_STATUS] + )['data'], + 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 df27e2a6d..e4a28c7dc 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' ), ]