kopia lustrzana https://github.com/wagtail/wagtail
Optimise queries in page listing views by prefetching workflow states of the parent page
rodzic
0fcdd08bf0
commit
ad6688f2da
|
@ -796,7 +796,7 @@ class TestInWorkflowStatus(WagtailTestUtils, TestCase):
|
||||||
# Warm up cache
|
# Warm up cache
|
||||||
self.client.get(self.url)
|
self.client.get(self.url)
|
||||||
|
|
||||||
with self.assertNumQueries(50):
|
with self.assertNumQueries(47):
|
||||||
response = self.client.get(self.url)
|
response = self.client.get(self.url)
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
|
@ -73,7 +73,9 @@ class IndexView(PermissionCheckedMixin, BaseListingView):
|
||||||
|
|
||||||
def get(self, request, parent_page_id=None):
|
def get(self, request, parent_page_id=None):
|
||||||
if parent_page_id:
|
if parent_page_id:
|
||||||
self.parent_page = get_object_or_404(Page, id=parent_page_id)
|
self.parent_page = get_object_or_404(
|
||||||
|
Page.objects.all().prefetch_workflow_states(), id=parent_page_id
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.parent_page = Page.get_first_root_node()
|
self.parent_page = Page.get_first_root_node()
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue