Merge pull request #3130 from alphagov/notification-coubt

Get notification count from api instead of getting list of notifications from api
This commit is contained in:
Pea (Malgorzata Tyczynska)
2019-10-08 12:19:55 +01:00
committed by GitHub
4 changed files with 19 additions and 10 deletions

View File

@@ -176,10 +176,10 @@ def cancel_job(service_id, job_id):
def cancel_letter_job(service_id, job_id):
if request.method == 'POST':
job = job_api_client.get_job(service_id, job_id)['data']
notifications = notification_api_client.get_notifications_for_service(
job['service'], job['id']
)['notifications']
if job['job_status'] != 'finished' or len(notifications) < job['notification_count']:
notification_count = notification_api_client.get_notification_count_for_job_id(
service_id=service_id, job_id=job_id
)
if job['job_status'] != 'finished' or notification_count < job['notification_count']:
flash("We are still processing these letters, please try again in a minute.", 'try again')
return view_job(service_id, job_id)
try: