Skip to content

fix(search): Refactor cl.lib.search_utils.fetch_and_paginate_results … #5931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

amattalols
Copy link
Contributor

…to cache only ES Response objects and create Paginator.Page objects from the results. Requires enriching the results after fetching from the cache, so there is still additional possible performance increase by refactoring enrichment functions to process the ES Response rather than the Page objects.

Fixes #5562.

…to cache only ES Response objects and create Paginator.Page objects from the results. Requires enriching the results after fetching from the cache, so there is still additional possible performance increase by refactoring enrichment functions to process the ES Response rather than the Page objects. Fixes freelawproject#5562.
@CLAassistant
Copy link

CLAassistant commented Jul 8, 2025

CLA assistant check
All committers have signed the CLA.

@mlissner
Copy link
Member

mlissner commented Jul 9, 2025

Thank you @amattalols! I'm assigning to @albertisfu for review during this sprint (which ends Friday).

@mlissner
Copy link
Member

mlissner commented Jul 9, 2025

Alberto, I put this on your todo, but perhaps we should push until Jamaica sprint. If so, no worries, just go ahead and push it if you want. :)

@albertisfu albertisfu moved this from To Do to In progress in Sprint (Web Team) Jul 16, 2025
Copy link
Contributor

@albertisfu albertisfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @amattalols, for your work on this issue. The PR looks great! just a minor comment to address.


elif type(cache_data) is Response:
# Create Django paginator for insights as ES metadata is not stored
paginator = Paginator(cache_data, page)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to use rows_per_page here; otherwise, only one result will be displayed on the home page for the latest opinions.

Suggested change
paginator = Paginator(cache_data, page)
paginator = Paginator(cache_data, rows_per_page)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you're right. Fixed in latest commit.

@albertisfu albertisfu moved this from In progress to Blocked in Sprint (Web Team) Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Blocked
Development

Successfully merging this pull request may close these issues.

Stop caching the page object for the search micro-cache
4 participants