mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-17 04:59:37 -04:00
Cache organisation name in Redis
A lot of pages in the admin app are now generated entirely from Redis, without touching the API. The one remaining API call that a lot of pages make, when the user is platform admin or a member of an organisation, is to get the name of the current service’s organisation. This commit adds some code to start caching that as well, which should speed up page load times for when we’re clicking around the admin app (it’s typically 100ms just to get the organisation, and more than that when the API is under load). This means changing the service model to get the organisation from the API by ID, not by service ID. Otherwise it would be very hard to clear the cache if the name of the organisation ever changed. We can’t cache the whole organisation because it has a `count_of_live_services` field which can change at any time, without an update being made.
This commit is contained in:
@@ -3113,7 +3113,7 @@ def mock_get_organisation(mocker):
|
||||
'o1': 'Org 1',
|
||||
'o2': 'Org 2',
|
||||
'o3': 'Org 3',
|
||||
}.get(org_id, 'Org 1'),
|
||||
}.get(org_id, 'Test organisation'),
|
||||
)
|
||||
|
||||
return mocker.patch('app.organisations_client.get_organisation', side_effect=_get_organisation)
|
||||
@@ -3130,6 +3130,14 @@ def mock_get_organisation_by_domain(mocker):
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_no_organisation_by_domain(mocker):
|
||||
return mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
return_value=None,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_get_service_organisation(
|
||||
mocker,
|
||||
|
||||
Reference in New Issue
Block a user