From 606f8607c20e36523843af16dfdc18a983d9d98a Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Wed, 7 Feb 2024 14:27:45 +0000 Subject: [PATCH] Compare locked_by_id to avoid fetching user object in _locked_indicator.html --- .../wagtailadmin/pages/listing/_locked_indicator.html | 4 ++-- wagtail/admin/tests/pages/test_dashboard.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wagtail/admin/templates/wagtailadmin/pages/listing/_locked_indicator.html b/wagtail/admin/templates/wagtailadmin/pages/listing/_locked_indicator.html index 7b39645bd3..6964d6b60d 100644 --- a/wagtail/admin/templates/wagtailadmin/pages/listing/_locked_indicator.html +++ b/wagtail/admin/templates/wagtailadmin/pages/listing/_locked_indicator.html @@ -8,8 +8,8 @@ {% if page.locked %} {% icon name="lock" classname="initial" %} diff --git a/wagtail/admin/tests/pages/test_dashboard.py b/wagtail/admin/tests/pages/test_dashboard.py index c46e21f843..6b51326b9c 100644 --- a/wagtail/admin/tests/pages/test_dashboard.py +++ b/wagtail/admin/tests/pages/test_dashboard.py @@ -186,7 +186,7 @@ class TestRecentEditsQueryCount(WagtailTestUtils, TestCase): # Warm up the cache html = panel.render_html(parent_context) - with self.assertNumQueries(14): + with self.assertNumQueries(12): # Rendering RecentEditsPanel should not generate N+1 queries - # i.e. any number less than 6 would be reasonable here html = panel.render_html(parent_context) @@ -229,7 +229,7 @@ class TestLockedPagesQueryCount(WagtailTestUtils, TestCase): # Warm up the cache html = panel.render_html(parent_context) - with self.assertNumQueries(4): + with self.assertNumQueries(1): html = panel.render_html(parent_context) soup = self.get_soup(html) # Should be sorted descending by locked_at @@ -297,7 +297,7 @@ class UserObjectsInWorkflowModerationQueryCount(WagtailTestUtils, TestCase): # Warm up the cache html = panel.render_html(parent_context) - with self.assertNumQueries(6): + with self.assertNumQueries(4): html = panel.render_html(parent_context) soup = self.get_soup(html) @@ -387,7 +387,7 @@ class WorkflowObjectsToModerateQueryCount(WagtailTestUtils, TestCase): # Warm up the cache html = panel.render_html(parent_context) - with self.assertNumQueries(40): + with self.assertNumQueries(38): html = panel.render_html(parent_context) soup = self.get_soup(html)