Skip to content

feat: filter pages queryset more efficiently [CDD-3506] - #3296

Open
jrdh wants to merge 1 commit into
fix/cdd-3498-resolve-page-classification-clashesfrom
fix/cdd-3506-based-on-3498
Open

jrdh wants to merge 1 commit into
fix/cdd-3498-resolve-page-classification-clashesfrom
fix/cdd-3506-based-on-3498

Conversation

@jrdh

@jrdh jrdh commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

Filter pages querysets more efficiently. This change adds two filter functions which can query for public and non-public pages using a single query instead of several. The queryset is also not resolved during viewset's get_queryset method.

The functions use subqueries to ensure the correct pages are filtered in and out of queries. Originally left outer joins was prefered as the best approach, however this proved incompatible with wagtail's search backend framework, whereas subqueries works.

This supersedes https://github.com/UKHSA-Internal/data-dashboard api/pull/3293 with similar performance (slightly fewer total queries):

list view including public pages:

  • 165ms overall
  • 35ms on queries
  • 33 queries

list view including permitted non-public pages:

  • 164ms overall
  • 34ms on queries
  • 33 queries

Fixes #CDD-3506


Type of change

Please select the options that are relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Tech debt item (this is focused solely on addressing any relevant technical debt)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests at the right levels to prove my change is effective
  • I have added screenshots or screen grabs where appropriate
  • I have added docstrings in the correct style (google)

@jrdh
jrdh requested a review from a team as a code owner August 3, 2026 23:27
@jrdh
jrdh force-pushed the fix/cdd-3498-resolve-page-classification-clashes branch from fc6a36e to b9d10df Compare August 4, 2026 07:46
@jrdh
jrdh force-pushed the fix/cdd-3506-based-on-3498 branch from 84c8a76 to e8dd16f Compare August 4, 2026 07:52
@jrdh
jrdh marked this pull request as draft August 7, 2026 08:29
@jrdh
jrdh force-pushed the fix/cdd-3498-resolve-page-classification-clashes branch from fb557ce to 00ba02b Compare August 7, 2026 10:06
@jrdh
jrdh force-pushed the fix/cdd-3506-based-on-3498 branch from d406fcc to 5164df3 Compare August 11, 2026 21:29
@jrdh
jrdh force-pushed the fix/cdd-3498-resolve-page-classification-clashes branch from 00ba02b to 3534333 Compare August 11, 2026 21:31
@jrdh
jrdh force-pushed the fix/cdd-3506-based-on-3498 branch from 5164df3 to 1977a62 Compare August 11, 2026 21:32
@jrdh jrdh changed the title feat: filter pages queryset more efficiently feat: filter pages queryset more efficiently [CDD-3506] Aug 11, 2026
@jrdh
jrdh force-pushed the fix/cdd-3506-based-on-3498 branch 2 times, most recently from 28f216f to 1c943e5 Compare August 11, 2026 21:43
@jrdh
jrdh marked this pull request as ready for review August 11, 2026 22:04
@jrdh
jrdh force-pushed the fix/cdd-3506-based-on-3498 branch from 1c943e5 to e6bd2b4 Compare August 19, 2026 20:07
This change adds two filter functions which can query for public and non-public
pages using a single query instead of several. The queryset is also not resolved
during viewset's `get_queryset` method.

The functions use subqueries to ensure the correct pages are filtered in and out
of queries. Originally left outer joins was prefered as the best approach, however
this proved incompatible with wagtail's search backend framework, whereas subqueries
works.
@jrdh
jrdh force-pushed the fix/cdd-3506-based-on-3498 branch from e6bd2b4 to d590a4f Compare August 19, 2026 20:15
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants