From 7b9df8de2978343b7b9360c034a5d79b8260cbe2 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Thu, 27 Sep 2018 14:51:36 +0100 Subject: [PATCH] Fix download csv to use the service data retention if it exists. --- app/main/views/notifications.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index 76f65d8af..e0385f56d 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -23,6 +23,7 @@ from app import ( format_date_numeric, job_api_client, notification_api_client, + service_api_client, ) from app.main import main from app.notify_client.api_key_api_client import KEY_TYPE_TEST @@ -167,6 +168,9 @@ def download_notifications_csv(service_id): filter_args = parse_filter_args(request.args) filter_args['status'] = set_status_filters(filter_args) + service_data_retention_days = service_api_client.get_service_data_retention_by_notification_type( + service_id, filter_args.get('message_type')[0] + ).get('days_of_retention', current_app.config['ACTIVITY_STATS_LIMIT_DAYS']) return Response( stream_with_context( generate_notifications_csv( @@ -177,7 +181,7 @@ def download_notifications_csv(service_id): page_size=10000, format_for_csv=True, template_type=filter_args.get('message_type'), - limit_days=current_app.config['ACTIVITY_STATS_LIMIT_DAYS'], + limit_days=service_data_retention_days, ) ), mimetype='text/csv',