-
Notifications
You must be signed in to change notification settings - Fork 198
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 fetching search results and handle fetching errors #2618
Conversation
Size Change: +506 B (0%) Total Size: 839 kB
ℹ️ View Unchanged
|
672cbb3
to
99ab42e
Compare
99ab42e
to
48790cd
Compare
48790cd
to
ced64dd
Compare
d8a1a0b
to
9915ead
Compare
d2dd848
to
b2460a2
Compare
30f314e
to
82e52b6
Compare
99af1d3
to
5862fda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes generally make sense to me! I followed the testing instructions and everything worked as expected.
/** | ||
* Search middleware runs when the path changes. This watcher | ||
* is necessary to handle the query changes. | ||
* | ||
* It updates the search store state from the URL query, | ||
* fetches media, and scrolls to top if necessary. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding these comments!
5862fda
to
fb8f0d2
Compare
Based on the high urgency of this PR, the following reviewers are being gently reminded to review this PR: @dhruvkb Excluding weekend1 days, this PR was ready for review 3 day(s) ago. PRs labelled with high urgency are expected to be reviewed within 2 weekday(s)2. @obulat, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, works well!
In the
media
store, we setfetchingError
to 404 status in case there are no results, to show the 404 page.
This seems wrong to me. If we have no results for a query, that does not imply 404 because the /search
page itself still exists.
Right, I haven't thought about it. Thank you, Dhruv! |
fb8f0d2
to
e8e08d9
Compare
10fb0c7
to
421bafc
Compare
I updated the PR to set the error to |
89efb8e
to
989d8f5
Compare
989d8f5
to
6880335
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! I appreciate your quick turnaround on the requested changes.
Fixes
Fixes #2588 by @obulat
Description
This PR moves the fetching of search results from the
asyncData
to thesearch
middleware and theuseFetch
hook in thesearch.vue
page.Fetching search results on the server
Just like in the single result pages, on the server, we make sure that we can fetch the data or redirect to the Nuxt error page. In the
search.vue
page, we setfetchOnServer
to false so that the data that was fetched on the server (if the search page was opened directly, when you go to https://openverse.org/search/?q=cat) isn't refetched when the page is hydrating.Fetching search results on the client
If we navigate to the search page from other pages (homepage or 404 page), the
useFetch
callsfetchMedia
insearch.vue
to get the search results. If the route changes (either the path, i.e. when the search type changes, or the query, i.e., when the search term, or filters change), the router watch callsfetchMedia
insearch.vue
.Updating the provider filters
Previously,
asyncData
updated the search state and provider filters. Here, this is moved to thesearch
middleware.Fetching errors
When there are no search results for a query, we receive a 200 response with an empty result list. In the
media
store, we setfetchingError
to 404 status in case there are no results, to show the 404 page.fetchingError.message
toNO_RESULT
to show the No results page.All content errors
This PR updates the handling of the "All content" errors: if there is even a single 429 error, we set the combined
allMediaError
status to 429, because it means that all client searches will be throttled.After @dhruvkb's request for change, I've updatedallMediaError
is set to 404 status only if thefetchingError
s for all media types is 404, so we only show a 404 page for "All content" if both audio and image had no results.allMediaError
to set aNO_RESULT
error message if there are no results for all supported media types. Otherwise, we show the available media type results.Testing Instructions
Searching from the homepage and 404 page, as well as from the search page's header should work correctly.
Clicking "Load more" should load the next page of the results for all search types.
For all media, check cases with only one type of results, such as "ecommerce image".
Also, try queries that don't have any results (such as "querywithnoresults").
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin