wcs: reduce querysets on page detail for user (#40675)

This commit is contained in:
Lauréline Guérin 2020-03-10 14:31:45 +01:00
parent 3b75d3db28
commit c5c2a66a60
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 8 additions and 5 deletions

View File

@ -22,10 +22,13 @@ from django.utils.translation import ugettext_lazy as _
def user_get_name_id(user):
saml_identifier = user.saml_identifiers.first()
if saml_identifier:
return saml_identifier.name_id
return None
if not hasattr(user, '_name_id'):
user._name_id = None
saml_identifier = user.saml_identifiers.first()
if saml_identifier:
user._name_id = saml_identifier.name_id
return user._name_id
class AppConfig(django.apps.AppConfig):

View File

@ -1228,7 +1228,7 @@ def test_view_page_with_wcs_cells_num_queries(app, admin_user):
app.get('/') # load once to populate caches
with CaptureQueriesContext(connection) as ctx:
app.get('/')
assert len(ctx.captured_queries) == 160
assert len(ctx.captured_queries) == 61
@wcs_present