Skip to content
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

Fix broken template rendering on /search requests #8757

Conversation

ddominguez
Copy link
Contributor

Work search template expects a SearchResponse object, but None was being sent if the request did not have any params. Updated request to always send a SearchResponse object.

Also, removed an unused import.

Closes #8730

Fix the broken rendering issues on the '/search' page when there are no query params.

Technical

There was existing logic to prevent the solr search query from being executed if the param dict was empty. I am assuming this was done to prevent a db hit. Executing the search query with the empty param was a solution that I tested and worked but I decided to send back an empty SearchResponse.

Testing

These are the steps I took to test.

  1. Visit the /search page. Search form should be rendered.
  2. Go to /advancedsearch and submit and empty search. This will redirect to /search and the Search form should render.
  3. In the top search box, select the ALL filter and submit an empty search. This will redirect to /search and the Search form should render.

Screenshot

Stakeholders

ddominguez and others added 2 commits January 24, 2024 21:59
Work search template expects a SearchResponse object,
but None was being sent if the request did not have any params.
Updated request to always send a SearchResponse object.

Also, removed an unused import.
@@ -19,7 +19,6 @@
from openlibrary.core import cache
from openlibrary.core.lending import add_availability
from openlibrary.core.models import Edition
from openlibrary.plugins.inside.code import fulltext_search
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused import

@cdrini cdrini self-assigned this Jan 27, 2024
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

Lgtm! Good solution :) Tested on testing.openlibrary.org and works like a charm. Thank you @ddominguez !

@cdrini cdrini merged commit efa7fae into internetarchive:master Jan 27, 2024
3 checks passed
Achorn pushed a commit to Achorn/openlibrary that referenced this pull request Mar 14, 2024
* Fix broken template rendering on /search requests

Work search template expects a SearchResponse object,
but None was being sent if the request did not have any params.
Updated request to always send a SearchResponse object.

Also, removed an unused import.
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.

Unable to render this page Error when no parameters are passed to search page.
2 participants