Merge pull request #2334 from alphagov/fix-download-bug

Fix download csv to use the service data retention if it exists.
This commit is contained in:
Rebecca Law
2018-09-27 16:07:17 +01:00
committed by GitHub

View File

@@ -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',