mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 10:28:41 -04:00
Report performance platform report
We used to upload this to performance platform to show the list of services and organisations. There is no longer a performance platform to upload this file to.
This commit is contained in:
@@ -245,33 +245,6 @@ def live_services_csv():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@main.route("/platform-admin/reports/performance-platform.xlsx")
|
|
||||||
@user_is_platform_admin
|
|
||||||
def performance_platform_xlsx():
|
|
||||||
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" if row["live_date"] else None,
|
|
||||||
"govuk-notify",
|
|
||||||
1
|
|
||||||
])
|
|
||||||
|
|
||||||
return Spreadsheet.from_rows(live_services_data).as_excel_file, 200, {
|
|
||||||
'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
||||||
'Content-Disposition': 'attachment; filename="{} performance platform report.xlsx"'.format(
|
|
||||||
format_date_numeric(datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ")),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@main.route("/platform-admin/reports/notifications-sent-by-service", methods=['GET', 'POST'])
|
@main.route("/platform-admin/reports/notifications-sent-by-service", methods=['GET', 'POST'])
|
||||||
@user_is_platform_admin
|
@user_is_platform_admin
|
||||||
def notifications_sent_by_service():
|
def notifications_sent_by_service():
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ class HeaderNavigation(Navigation):
|
|||||||
'live_services',
|
'live_services',
|
||||||
'live_services_csv',
|
'live_services_csv',
|
||||||
'notifications_sent_by_service',
|
'notifications_sent_by_service',
|
||||||
'performance_platform_xlsx',
|
|
||||||
'usage_for_all_services',
|
'usage_for_all_services',
|
||||||
'organisations',
|
'organisations',
|
||||||
'platform_admin',
|
'platform_admin',
|
||||||
@@ -650,7 +649,6 @@ class MainNavigation(Navigation):
|
|||||||
'organisation_settings',
|
'organisation_settings',
|
||||||
'organisations',
|
'organisations',
|
||||||
'performance',
|
'performance',
|
||||||
'performance_platform_xlsx',
|
|
||||||
'platform_admin',
|
'platform_admin',
|
||||||
'platform_admin_list_complaints',
|
'platform_admin_list_complaints',
|
||||||
'platform_admin_reports',
|
'platform_admin_reports',
|
||||||
@@ -919,7 +917,6 @@ class CaseworkNavigation(Navigation):
|
|||||||
'organisation_settings',
|
'organisation_settings',
|
||||||
'organisations',
|
'organisations',
|
||||||
'performance',
|
'performance',
|
||||||
'performance_platform_xlsx',
|
|
||||||
'platform_admin_list_complaints',
|
'platform_admin_list_complaints',
|
||||||
'platform_admin_reports',
|
'platform_admin_reports',
|
||||||
'platform_admin_returned_letters',
|
'platform_admin_returned_letters',
|
||||||
@@ -1239,7 +1236,6 @@ class OrgNavigation(Navigation):
|
|||||||
'old_using_notify',
|
'old_using_notify',
|
||||||
'organisations',
|
'organisations',
|
||||||
'performance',
|
'performance',
|
||||||
'performance_platform_xlsx',
|
|
||||||
'platform_admin',
|
'platform_admin',
|
||||||
'platform_admin_list_complaints',
|
'platform_admin_list_complaints',
|
||||||
'platform_admin_reports',
|
'platform_admin_reports',
|
||||||
|
|||||||
@@ -13,14 +13,9 @@
|
|||||||
<p class="govuk-body">
|
<p class="govuk-body">
|
||||||
<a class="govuk-link govuk-link--no-visited-state" target="_blank" href="{{ url_for('main.live_services_csv') }}">Download live services csv report</a>
|
<a class="govuk-link govuk-link--no-visited-state" target="_blank" href="{{ url_for('main.live_services_csv') }}">Download live services csv report</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="govuk-body">
|
|
||||||
<a class="govuk-link govuk-link--no-visited-state" target="_blank" href="{{ url_for('main.performance_platform_xlsx') }}">Download performance platform report (.xlsx)</a>
|
|
||||||
<p class="govuk-body">
|
|
||||||
|
|
||||||
<p class="govuk-body">
|
<p class="govuk-body">
|
||||||
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.notifications_sent_by_service') }}">Monthly notification statuses for live services</a>
|
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.notifications_sent_by_service') }}">Monthly notification statuses for live services</a>
|
||||||
<p class="govuk-body">
|
</p>
|
||||||
<p class="govuk-body">
|
<p class="govuk-body">
|
||||||
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.usage_for_all_services') }}">Usage for all services</a>
|
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.usage_for_all_services') }}">Usage for all services</a>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import uuid
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from unittest.mock import ANY, call
|
from unittest.mock import ANY, call
|
||||||
|
|
||||||
import pyexcel
|
|
||||||
import pytest
|
import pytest
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
@@ -760,10 +759,6 @@ def test_reports_page(
|
|||||||
'a', text="Download live services csv report"
|
'a', text="Download live services csv report"
|
||||||
).attrs['href'] == '/platform-admin/reports/live-services.csv'
|
).attrs['href'] == '/platform-admin/reports/live-services.csv'
|
||||||
|
|
||||||
assert page.find(
|
|
||||||
'a', text="Download performance platform report (.xlsx)"
|
|
||||||
).attrs['href'] == '/platform-admin/reports/performance-platform.xlsx'
|
|
||||||
|
|
||||||
assert page.find(
|
assert page.find(
|
||||||
'a', text="Monthly notification statuses for live services"
|
'a', text="Monthly notification statuses for live services"
|
||||||
).attrs['href'] == url_for('main.notifications_sent_by_service')
|
).attrs['href'] == url_for('main.notifications_sent_by_service')
|
||||||
@@ -803,35 +798,6 @@ def test_get_live_services_report(platform_admin_client, mocker):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_performance_platform_report(platform_admin_client, mocker):
|
|
||||||
|
|
||||||
mocker.patch(
|
|
||||||
'app.service_api_client.get_live_services_data',
|
|
||||||
return_value={'data': [
|
|
||||||
{'service_id': 'abc123', 'service_name': 'jessie the oak tree', 'organisation_name': 'Forest',
|
|
||||||
'consent_to_research': True, 'contact_name': 'Forest fairy', 'organisation_type': 'Ecosystem',
|
|
||||||
'contact_email': 'forest.fairy@digital.cabinet-office.gov.uk', 'contact_mobile': '+447700900986',
|
|
||||||
'live_date': 'Sat, 29 Mar 2014 00:00:00 GMT', 'sms_volume_intent': 100, 'email_volume_intent': 50,
|
|
||||||
'letter_volume_intent': 20, 'sms_totals': 300, 'email_totals': 1200, 'letter_totals': 0},
|
|
||||||
{'service_id': 'def456', 'service_name': 'james the pine tree', 'organisation_name': 'Forest',
|
|
||||||
'consent_to_research': None, 'contact_name': None, 'organisation_type': 'Ecosystem',
|
|
||||||
'contact_email': None, 'contact_mobile': None,
|
|
||||||
'live_date': None, 'sms_volume_intent': None, 'email_volume_intent': 60,
|
|
||||||
'letter_volume_intent': 0, 'sms_totals': 0, 'email_totals': 0, 'letter_totals': 0},
|
|
||||||
]}
|
|
||||||
)
|
|
||||||
response = platform_admin_client.get(url_for('main.performance_platform_xlsx'))
|
|
||||||
assert response.status_code == 200
|
|
||||||
assert pyexcel.get_array(
|
|
||||||
file_type='xlsx',
|
|
||||||
file_stream=response.get_data(),
|
|
||||||
) == [
|
|
||||||
['service_id', 'agency', 'service_name', '_timestamp', 'service', 'count'],
|
|
||||||
['abc123', 'Forest', 'jessie the oak tree', '2014-03-29T00:00:00Z', 'govuk-notify', 1],
|
|
||||||
['def456', 'Forest', 'james the pine tree', '', 'govuk-notify', 1],
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_notifications_sent_by_service_shows_date_form(client_request, platform_admin_user):
|
def test_get_notifications_sent_by_service_shows_date_form(client_request, platform_admin_user):
|
||||||
client_request.login(platform_admin_user)
|
client_request.login(platform_admin_user)
|
||||||
page = client_request.get('main.notifications_sent_by_service')
|
page = client_request.get('main.notifications_sent_by_service')
|
||||||
|
|||||||
Reference in New Issue
Block a user