mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-23 09:29:14 -04:00
Add Service.get_days_of_retention helper method
Data retention lookup by type is only performed to get the number of days, so we can update the service method to return the number or the default directly.
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
from flask import (
|
||||
Response,
|
||||
abort,
|
||||
current_app,
|
||||
jsonify,
|
||||
redirect,
|
||||
render_template,
|
||||
@@ -226,9 +225,7 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
service_data_retention_days = None
|
||||
|
||||
if message_type is not None:
|
||||
service_data_retention_days = current_service.get_data_retention_by_type(
|
||||
message_type
|
||||
).get('days_of_retention', current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
|
||||
service_data_retention_days = current_service.get_days_of_retention(message_type)
|
||||
|
||||
if request.path.endswith('csv') and current_user.has_permissions('view_activity'):
|
||||
return Response(
|
||||
@@ -406,9 +403,7 @@ def get_job_partials(job, template):
|
||||
counts=_get_job_counts(job),
|
||||
status=filter_args['status']
|
||||
)
|
||||
service_data_retention_days = current_service.get_data_retention_by_type(
|
||||
template['template_type']
|
||||
).get('days_of_retention', current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
|
||||
service_data_retention_days = current_service.get_days_of_retention(template['template_type'])
|
||||
|
||||
return {
|
||||
'counts': counts,
|
||||
|
||||
@@ -8,7 +8,6 @@ from dateutil import parser
|
||||
from flask import (
|
||||
Response,
|
||||
abort,
|
||||
current_app,
|
||||
jsonify,
|
||||
render_template,
|
||||
request,
|
||||
@@ -197,9 +196,7 @@ 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 = current_service.get_data_retention_by_type(
|
||||
filter_args.get('message_type')[0]
|
||||
).get('days_of_retention', current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
|
||||
service_data_retention_days = current_service.get_days_of_retention(filter_args.get('message_type')[0])
|
||||
return Response(
|
||||
stream_with_context(
|
||||
generate_notifications_csv(
|
||||
|
||||
Reference in New Issue
Block a user