mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Merge pull request #2224 from alphagov/notifications-page-data-retention-period
Notifications page data retention period
This commit is contained in:
@@ -216,6 +216,11 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
abort(404)
|
||||
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, message_type
|
||||
).get('days_of_retention', current_app.config['ACTIVITY_STATS_LIMIT_DAYS'])
|
||||
|
||||
if request.path.endswith('csv') and current_user.has_permissions('view_activity'):
|
||||
return Response(
|
||||
generate_notifications_csv(
|
||||
@@ -224,7 +229,7 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
page_size=5000,
|
||||
template_type=[message_type],
|
||||
status=filter_args.get('status'),
|
||||
limit_days=current_app.config['ACTIVITY_STATS_LIMIT_DAYS']
|
||||
limit_days=service_data_retention_days
|
||||
),
|
||||
mimetype='text/csv',
|
||||
headers={
|
||||
@@ -235,7 +240,7 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
page=page,
|
||||
template_type=[message_type] if message_type else [],
|
||||
status=filter_args.get('status'),
|
||||
limit_days=current_app.config['ACTIVITY_STATS_LIMIT_DAYS'],
|
||||
limit_days=service_data_retention_days,
|
||||
to=request.form.get('to', ''),
|
||||
)
|
||||
url_args = {
|
||||
@@ -262,13 +267,18 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
download_link = None
|
||||
|
||||
return {
|
||||
'service_data_retention_days': service_data_retention_days,
|
||||
'counts': render_template(
|
||||
'views/activity/counts.html',
|
||||
status=request.args.get('status'),
|
||||
status_filters=get_status_filters(
|
||||
current_service,
|
||||
message_type,
|
||||
service_api_client.get_service_statistics(service_id, today_only=False)
|
||||
service_api_client.get_service_statistics(
|
||||
service_id,
|
||||
today_only=False,
|
||||
limit_days=service_data_retention_days
|
||||
)
|
||||
)
|
||||
),
|
||||
'notifications': render_template(
|
||||
@@ -277,6 +287,7 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
notifications['notifications']
|
||||
)),
|
||||
page=page,
|
||||
limit_days=service_data_retention_days,
|
||||
prev_page=prev_page,
|
||||
next_page=next_page,
|
||||
status=request.args.get('status'),
|
||||
|
||||
@@ -41,8 +41,10 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
"""
|
||||
return self.get('/service/{0}'.format(service_id))
|
||||
|
||||
def get_service_statistics(self, service_id, today_only):
|
||||
return self.get('/service/{0}/statistics'.format(service_id), params={'today_only': today_only})['data']
|
||||
def get_service_statistics(self, service_id, today_only, limit_days=None):
|
||||
return self.get('/service/{0}/statistics'.format(service_id), params={
|
||||
'today_only': today_only, 'limit_days': limit_days
|
||||
})['data']
|
||||
|
||||
def get_services(self, params_dict=None):
|
||||
"""
|
||||
@@ -498,5 +500,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
def get_service_data_retention(self, service_id):
|
||||
return self.get("/service/{}/data-retention".format(service_id))
|
||||
|
||||
def get_service_data_retention_by_notification_type(self, service_id, notification_type):
|
||||
return self.get("/service/{}/data-retention/notification-type/{}".format(service_id, notification_type))
|
||||
|
||||
def get_service_data_retention_by_id(self, service_id, data_retention_id):
|
||||
return self.get("service/{}/data-retention/{}".format(service_id, data_retention_id))
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
notifications,
|
||||
caption="Recent activity",
|
||||
caption_visible=False,
|
||||
empty_message='No messages found  (messages are kept for 7 days)'|safe,
|
||||
empty_message='No messages found  (messages are kept for {} days)'.format(limit_days)|safe,
|
||||
field_headings=['Recipient', 'Status'],
|
||||
field_headings_visible=False
|
||||
) %}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<p class="bottom-gutter">
|
||||
<a href="{{ download_link }}" download="download" class="heading-small">Download this report</a>
|
||||
 
|
||||
Data available for 7 days
|
||||
Data available for {{ partials.service_data_retention_days }} days
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user