api: prefetch roles on agenda display (#57670)
This commit is contained in:
parent
5d1390223e
commit
a7757b7a22
|
@ -706,7 +706,7 @@ class Agendas(APIView):
|
|||
def get(self, request, format=None):
|
||||
agendas_queryset = (
|
||||
Agenda.objects.all()
|
||||
.select_related('absence_reasons_group', 'category')
|
||||
.select_related('absence_reasons_group', 'category', 'edit_role', 'view_role')
|
||||
.prefetch_related('resources', 'absence_reasons_group__absence_reasons')
|
||||
.order_by('label')
|
||||
)
|
||||
|
|
|
@ -181,10 +181,10 @@ def test_agendas_api(app):
|
|||
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.get('/api/agenda/')
|
||||
assert len(ctx.captured_queries) == 8
|
||||
assert len(ctx.captured_queries) == 4
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.get('/api/agenda/', params={'q': 'MEET'})
|
||||
assert len(ctx.captured_queries) == 3
|
||||
assert len(ctx.captured_queries) == 2
|
||||
|
||||
resp = app.get('/api/agenda/', params={'with_open_events': '1'})
|
||||
assert len(resp.json['data']) == 0
|
||||
|
@ -291,7 +291,7 @@ def test_agendas_api(app):
|
|||
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.get('/api/agenda/', params={'with_open_events': '1'})
|
||||
assert len(ctx.captured_queries) == 9
|
||||
assert len(ctx.captured_queries) == 8
|
||||
|
||||
|
||||
def test_agendas_meetingtypes_api(app, some_data, meetings_agenda):
|
||||
|
|
Loading…
Reference in New Issue