mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-20 16:13:24 -04:00
Add performance platform csv report and format live dates
Drop redundant Response wrapper
This commit is contained in:
@@ -3,15 +3,7 @@ import re
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
|
||||
from flask import (
|
||||
Response,
|
||||
abort,
|
||||
flash,
|
||||
redirect,
|
||||
render_template,
|
||||
request,
|
||||
url_for,
|
||||
)
|
||||
from flask import abort, flash, redirect, render_template, request, url_for
|
||||
from flask_login import login_required
|
||||
from notifications_python_client.errors import HTTPError
|
||||
from requests import RequestException
|
||||
@@ -227,7 +219,7 @@ def live_services_csv():
|
||||
row["contact_name"],
|
||||
row["contact_email"],
|
||||
row["contact_mobile"],
|
||||
row["live_date"],
|
||||
datetime.strptime(row["live_date"], '%a, %d %b %Y %X %Z').strftime("%d-%m-%Y"),
|
||||
row["sms_volume_intent"],
|
||||
row["email_volume_intent"],
|
||||
row["letter_volume_intent"],
|
||||
@@ -235,15 +227,39 @@ def live_services_csv():
|
||||
row["email_totals"],
|
||||
row["letter_totals"],
|
||||
])
|
||||
return Response(
|
||||
Spreadsheet.from_rows(live_services_data).as_csv_data,
|
||||
mimetype='text/csv',
|
||||
headers={
|
||||
'Content-Disposition': 'inline; filename="{} live services report.csv"'.format(
|
||||
format_date_numeric(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
return Spreadsheet.from_rows(live_services_data).as_csv_data, 200, {
|
||||
'Content-Type': 'text/csv; charset=utf-8',
|
||||
'Content-Disposition': 'inline; filename="{} live services report.csv"'.format(
|
||||
format_date_numeric(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@main.route("/platform-admin/reports/performance-platform.csv")
|
||||
@login_required
|
||||
@user_is_platform_admin
|
||||
def performance_platform_csv():
|
||||
results = service_api_client.get_live_services_data()["data"]
|
||||
live_services_columns = ["service_id", "agency", "service_name", "_timestamp", "service", "count"]
|
||||
live_services_data = []
|
||||
live_services_data.append(live_services_columns)
|
||||
for row in results:
|
||||
live_services_data.append([
|
||||
row["service_id"],
|
||||
row["organisation_name"],
|
||||
row["service_name"],
|
||||
datetime.strptime(row["live_date"], '%a, %d %b %Y %X %Z').strftime("%Y-%m-%dT%H:%M:%S") + "Z",
|
||||
"govuk-notify",
|
||||
1
|
||||
])
|
||||
|
||||
return Spreadsheet.from_rows(live_services_data).as_csv_data, 200, {
|
||||
'Content-Type': 'text/csv; charset=utf-8',
|
||||
'Content-Disposition': 'inline; filename="{} performance platform report.csv"'.format(
|
||||
format_date_numeric(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@main.route("/platform-admin/complaints")
|
||||
|
||||
@@ -87,6 +87,7 @@ class HeaderNavigation(Navigation):
|
||||
'live_services',
|
||||
'live_services_csv',
|
||||
'organisations',
|
||||
'performance_platform_csv',
|
||||
'platform_admin',
|
||||
'platform_admin_letter_validation_preview',
|
||||
'platform_admin_list_complaints',
|
||||
@@ -493,6 +494,7 @@ class MainNavigation(Navigation):
|
||||
'organisation_preview_letter_branding',
|
||||
'organisation_settings',
|
||||
'organisations',
|
||||
'performance_platform_csv',
|
||||
'platform_admin',
|
||||
'platform_admin_letter_validation_preview',
|
||||
'platform_admin_list_complaints',
|
||||
@@ -709,6 +711,7 @@ class CaseworkNavigation(Navigation):
|
||||
'organisation_preview_letter_branding',
|
||||
'organisation_settings',
|
||||
'organisations',
|
||||
'performance_platform_csv',
|
||||
'platform_admin_letter_validation_preview',
|
||||
'platform_admin_list_complaints',
|
||||
'platform_admin_reports',
|
||||
@@ -964,6 +967,7 @@ class OrgNavigation(Navigation):
|
||||
'old_terms',
|
||||
'old_using_notify',
|
||||
'organisations',
|
||||
'performance_platform_csv',
|
||||
'platform_admin',
|
||||
'platform_admin_letter_validation_preview',
|
||||
'platform_admin_list_complaints',
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
Reports
|
||||
</h1>
|
||||
|
||||
<a target="_blank" href="{{ url_for('main.live_services_csv') }}">Download live services information sheet</a>
|
||||
<p>
|
||||
<a target="_blank" href="{{ url_for('main.live_services_csv') }}">Download live services csv report</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a target="_blank" href="{{ url_for('main.performance_platform_csv') }}">Download performance platform csv report</a>
|
||||
<p>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user