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

[Discover] Fix Initialization if No Saved Query #8930

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

Conversation

sejli
Copy link
Member

@sejli sejli commented Nov 26, 2024

Description

Upon Discover mount (when getSavedSearchById is called), we were either setting the query to be the saved search, if it exists, or the default query. In this PR, I updated the logic such that we use the current query instead, which should be the single entry point that also handles the default query state.

Issues Resolved

Screenshot

Testing the changes

Changelog

  • fix: Update saved search initialization logic to use current query instead of default query

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Sean Li <lnse@amazon.com>
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.88%. Comparing base (073a9ff) to head (646cca5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8930   +/-   ##
=======================================
  Coverage   60.87%   60.88%           
=======================================
  Files        3802     3802           
  Lines       91072    91072           
  Branches    14375    14374    -1     
=======================================
+ Hits        55444    55447    +3     
+ Misses      32086    32085    -1     
+ Partials     3542     3540    -2     
Flag Coverage Δ
Linux_1 29.02% <0.00%> (ø)
Linux_2 56.39% <ø> (ø)
Linux_3 37.90% <100.00%> (+<0.01%) ⬆️
Linux_4 29.00% <0.00%> (ø)
Windows_1 29.03% <0.00%> (ø)
Windows_2 56.34% <ø> (ø)
Windows_3 37.90% <100.00%> (+<0.01%) ⬆️
Windows_4 29.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Sean Li <lnse@amazon.com>
@@ -392,8 +392,7 @@ export const useSearch = (services: DiscoverViewServices) => {
const savedSearchInstance = await getSavedSearchById(savedSearchId);

const query =
savedSearchInstance.searchSource.getField('query') ||
data.query.queryString.getDefaultQuery();
Copy link
Contributor

Choose a reason for hiding this comment

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

Since .getDefaultQuery() isn't being used here, is it still used in other locations? I would've assumed I would see the removal of this function as well after reading the description

Copy link
Member

Choose a reason for hiding this comment

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

i dont know if we want removal of the function in general. but i understand what you mean it should probably be a private function within the query string manager.

@@ -432,7 +431,7 @@ export const useSearch = (services: DiscoverViewServices) => {
}

filterManager.setAppFilters(actualFilters);
data.query.queryString.setQuery(savedQuery ? data.query.queryString.getQuery() : query);
data.query.queryString.setQuery(query);
Copy link
Member

Choose a reason for hiding this comment

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

does this have any impact to saved queries? like logically to me when reading this this makes sense why we would remove it but save query expected functionality is a little weird to me. so if a saved query is applied and we update the query. but dont fire it's the correct bheavior here right

@kavilla kavilla added discover-next discover for discover reinvent labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants