Fix bug when live services have no organisation

The performance page expects all live services to have an organisation.
This should be true on production, but it isn’t always the case in
other environments.

When the organisation name is `None`, the frontend can’t sort the list
of organisations alphabetically and so raises an exception.
This commit is contained in:
Chris Hill-Scott
2021-03-15 09:42:06 +00:00
parent f424837429
commit 3ea9cba0bc
2 changed files with 12 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ def performance():
stats['organisations_using_notify'] = sorted(
[
{
'organisation_name': organisation_name,
'organisation_name': organisation_name or 'No organisation',
'count_of_live_services': len(list(group)),
}
for organisation_name, group in groupby(

View File

@@ -93,6 +93,15 @@ def _get_example_performance_data():
"service_id": uuid.uuid4(),
"service_name": "Example service 3"
},
{
# On production there should be no live services without an
# organisation, but this isnt always true in peoples local
# environments
"organisation_id": None,
"organisation_name": None,
"service_id": uuid.uuid4(),
"service_name": "Example service 4"
},
],
}
@@ -150,5 +159,6 @@ def test_should_render_performance_page(
'Organisations using Notify '
'Organisation Number of live services '
'Department of Examples and Patterns 2 '
'Department of One Service 1'
'Department of One Service 1 '
'No organisation 1'
)