prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Report pages performance regression
  ### Issue Summary
  
  Various report pages have a performance regression in Wagtail 5.2, which I've tracked down to:
  
  https://github.com/wagtail/wagtail/commit/7ba1afb8a402a09be5838a026523be78f08ea877
  https://github.com/wagtail/wagtail/pull/10822
  
  On a few sites we've upgraded to Wagtail 5.2 - performance in the Site History report has been significantly reduced:
  
  Before:
  <img width="1717" alt="Screenshot 2023-11-11 at 21 12 02" src="https://github.com/wagtail/wagtail/assets/177332/79650e6b-9c96-4d21-bbdf-23b98c862bf4">
  
  After:
  <img width="1716" alt="Screenshot 2023-11-11 at 21 13 09" src="https://github.com/wagtail/wagtail/assets/177332/e719e250-5c9c-4dc8-823b-1e1c3b40a74c">
  <img width="900" alt="Screenshot 2023-11-11 at 21 13 19" src="https://github.com/wagtail/wagtail/assets/177332/5623467b-a0ca-4472-aa46-540ff568ac82">
  
  ### Steps to Reproduce
  
  Find an existing Wagtail project with lots of pages, and log entries.
  
  Check http://127.0.0.1:9000/admin/reports/site-history/ with the project running Wagtail 5.2 - page will probably be slow to load.
  
  (Note: I did try and create a quick script to test this with Wagtail's starter project - but the performance of SQLite and a lack of a debug toolbar slowing things down made it a bit tricky!).
  
  -   I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes
  
  ### Technical details
  
  -   Python version: 3.11 / any
  -   Django version: 4.2 / any
  -   Wagtail version: 5.2 / main
  -   Browser version: n/a
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `wagtail/admin/views/reports/base.py`
  Content:
  ```
  1 from django.utils.translation import gettext_lazy as _
  2 
  3 from wagtail.admin.views.generic.models import IndexView
  4 
  5 
  6 class ReportView(IndexView):
  7     template_name = "wagtailadmin/reports/base_report.html"
  8     title = ""
  9     paginate_by = 50
  10 
  11     def get_filtered_queryset(self):
  12         return self.filter_queryset(self.get_queryset())
  13 
  14     def decorate_paginated_queryset(self, object_list):
  15         # A hook point to allow rewriting the object list after pagination has been applied
  16         return object_list
  17 
  18     def get(self, request, *args, **kwargs):
  19         self.filters, self.object_list = self.get_filtered_queryset()
  20         self.object_list = self.decorate_paginated_queryset(self.object_list)
  21         context = self.get_context_data()
  22         return self.render_to_response(context)
  23 
  24     def get_context_data(self, *args, **kwargs):
  25         context = super().get_context_data(*args, **kwargs)
  26         context["title"] = self.title
  27         return context
  28 
  29 
  30 class PageReportView(ReportView):
  31     template_name = "wagtailadmin/reports/base_page_report.html"
  32     export_headings = {
  33         "latest_revision_created_at": _("Updated"),
  34         "status_string": _("Status"),
  35         "content_type.model_class._meta.verbose_name.title": _("Type"),
  36     }
  37     list_export = [
  38         "title",
  39         "latest_revision_created_at",
  40         "status_string",
  41         "content_type.model_class._meta.verbose_name.title",
  42     ]
  43
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/wagtail/admin/views/reports/base.py b/wagtail/admin/views/reports/base.py
  --- a/wagtail/admin/views/reports/base.py
  +++ b/wagtail/admin/views/reports/base.py
  @@ -17,8 +17,12 @@
   
       def get(self, request, *args, **kwargs):
           self.filters, self.object_list = self.get_filtered_queryset()
  -        self.object_list = self.decorate_paginated_queryset(self.object_list)
           context = self.get_context_data()
  +        # Decorate the queryset *after* Django's BaseListView has returned a paginated/reduced
  +        # list of objects
  +        context["object_list"] = self.decorate_paginated_queryset(
  +            context["object_list"]
  +        )
           return self.render_to_response(context)
   
       def get_context_data(self, *args, **kwargs):
  
verification_info: {"golden_diff": "diff --git a/wagtail/admin/views/reports/base.py b/wagtail/admin/views/reports/base.py\n--- a/wagtail/admin/views/reports/base.py\n+++ b/wagtail/admin/views/reports/base.py\n@@ -17,8 +17,12 @@\n \n     def get(self, request, *args, **kwargs):\n         self.filters, self.object_list = self.get_filtered_queryset()\n-        self.object_list = self.decorate_paginated_queryset(self.object_list)\n         context = self.get_context_data()\n+        # Decorate the queryset *after* Django's BaseListView has returned a paginated/reduced\n+        # list of objects\n+        context[\"object_list\"] = self.decorate_paginated_queryset(\n+            context[\"object_list\"]\n+        )\n         return self.render_to_response(context)\n \n     def get_context_data(self, *args, **kwargs):\n", "issue": "Report pages performance regression\n### Issue Summary\r\n\r\nVarious report pages have a performance regression in Wagtail 5.2, which I've tracked down to:\r\n\r\nhttps://github.com/wagtail/wagtail/commit/7ba1afb8a402a09be5838a026523be78f08ea877\r\nhttps://github.com/wagtail/wagtail/pull/10822\r\n\r\nOn a few sites we've upgraded to Wagtail 5.2 - performance in the Site History report has been significantly reduced:\r\n\r\nBefore:\r\n<img width=\"1717\" alt=\"Screenshot 2023-11-11 at 21 12 02\" src=\"https://github.com/wagtail/wagtail/assets/177332/79650e6b-9c96-4d21-bbdf-23b98c862bf4\">\r\n\r\nAfter:\r\n<img width=\"1716\" alt=\"Screenshot 2023-11-11 at 21 13 09\" src=\"https://github.com/wagtail/wagtail/assets/177332/e719e250-5c9c-4dc8-823b-1e1c3b40a74c\">\r\n<img width=\"900\" alt=\"Screenshot 2023-11-11 at 21 13 19\" src=\"https://github.com/wagtail/wagtail/assets/177332/5623467b-a0ca-4472-aa46-540ff568ac82\">\r\n\r\n### Steps to Reproduce\r\n\r\nFind an existing Wagtail project with lots of pages, and log entries.\r\n\r\nCheck http://127.0.0.1:9000/admin/reports/site-history/ with the project running Wagtail 5.2 - page will probably be slow to load.\r\n\r\n(Note: I did try and create a quick script to test this with Wagtail's starter project - but the performance of SQLite and a lack of a debug toolbar slowing things down made it a bit tricky!).\r\n\r\n-   I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes\r\n\r\n### Technical details\r\n\r\n-   Python version: 3.11 / any\r\n-   Django version: 4.2 / any\r\n-   Wagtail version: 5.2 / main\r\n-   Browser version: n/a\n", "before_files": [{"content": "from django.utils.translation import gettext_lazy as _\n\nfrom wagtail.admin.views.generic.models import IndexView\n\n\nclass ReportView(IndexView):\n    template_name = \"wagtailadmin/reports/base_report.html\"\n    title = \"\"\n    paginate_by = 50\n\n    def get_filtered_queryset(self):\n        return self.filter_queryset(self.get_queryset())\n\n    def decorate_paginated_queryset(self, object_list):\n        # A hook point to allow rewriting the object list after pagination has been applied\n        return object_list\n\n    def get(self, request, *args, **kwargs):\n        self.filters, self.object_list = self.get_filtered_queryset()\n        self.object_list = self.decorate_paginated_queryset(self.object_list)\n        context = self.get_context_data()\n        return self.render_to_response(context)\n\n    def get_context_data(self, *args, **kwargs):\n        context = super().get_context_data(*args, **kwargs)\n        context[\"title\"] = self.title\n        return context\n\n\nclass PageReportView(ReportView):\n    template_name = \"wagtailadmin/reports/base_page_report.html\"\n    export_headings = {\n        \"latest_revision_created_at\": _(\"Updated\"),\n        \"status_string\": _(\"Status\"),\n        \"content_type.model_class._meta.verbose_name.title\": _(\"Type\"),\n    }\n    list_export = [\n        \"title\",\n        \"latest_revision_created_at\",\n        \"status_string\",\n        \"content_type.model_class._meta.verbose_name.title\",\n    ]\n", "path": "wagtail/admin/views/reports/base.py"}], "after_files": [{"content": "from django.utils.translation import gettext_lazy as _\n\nfrom wagtail.admin.views.generic.models import IndexView\n\n\nclass ReportView(IndexView):\n    template_name = \"wagtailadmin/reports/base_report.html\"\n    title = \"\"\n    paginate_by = 50\n\n    def get_filtered_queryset(self):\n        return self.filter_queryset(self.get_queryset())\n\n    def decorate_paginated_queryset(self, object_list):\n        # A hook point to allow rewriting the object list after pagination has been applied\n        return object_list\n\n    def get(self, request, *args, **kwargs):\n        self.filters, self.object_list = self.get_filtered_queryset()\n        context = self.get_context_data()\n        # Decorate the queryset *after* Django's BaseListView has returned a paginated/reduced\n        # list of objects\n        context[\"object_list\"] = self.decorate_paginated_queryset(\n            context[\"object_list\"]\n        )\n        return self.render_to_response(context)\n\n    def get_context_data(self, *args, **kwargs):\n        context = super().get_context_data(*args, **kwargs)\n        context[\"title\"] = self.title\n        return context\n\n\nclass PageReportView(ReportView):\n    template_name = \"wagtailadmin/reports/base_page_report.html\"\n    export_headings = {\n        \"latest_revision_created_at\": _(\"Updated\"),\n        \"status_string\": _(\"Status\"),\n        \"content_type.model_class._meta.verbose_name.title\": _(\"Type\"),\n    }\n    list_export = [\n        \"title\",\n        \"latest_revision_created_at\",\n        \"status_string\",\n        \"content_type.model_class._meta.verbose_name.title\",\n    ]\n", "path": "wagtail/admin/views/reports/base.py"}]}