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(queryEnhancements): data.search() should not ignore the strategy passed as parameter #8368

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ruanyl
Copy link
Member

@ruanyl ruanyl commented Sep 27, 2024

This is quick fix for the issue that the search strategy passed to data.search() API been completely ignored when query enhancement is enabled and the localStorage has a language preserved.

For example, selecting a language from discover language selector will make data.search() called with a specific strategy to use the language config stored in localStorage which is unexpected.

With this fix, language config is only used when search strategy is not passed specifically.

Sharing my two cents:

  1. I think it's better the language is passed as a parameter to data.search() instead of reading directly from query string manager(which has default value from local storage that different feature could share the same value). I think data.search() needs to be UI/feature-agnostic
  2. I'm fine with having different search intercepters for different languages, but it seems the current intercepters(ppl & sql) does way too much than than an "intercepter" should. IMHO, a search intercepter will just intercepts the search params(input) and search response(output), and does things like error handling, validation, etc. But now it seems we're building the search query in the intercepter by reading from some global state: time fitter, aggregation, etc. Shouldn't this be done upfront and passed to data.search() as search params?

I may not have a full picture of the entire idea of query enhancement, and I'm open to any other ideas :)

Description

Issues Resolved

Screenshot

Testing the changes

Changelog

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

…` passed as parameter

This is quick fix for the issue that the search strategy passed to
data.search() API been completely ignored when query enhancement is
enabled and the localStorage has a language preserved.

For example, selecting a language from discover language selector
will make data.search() called with a specific strategy to use the
language config stored in localStorage which is unexpected.

With this fix, language config is only used when search strategy is not
passed specifically.

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Copy link
Contributor

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

Copy link
Contributor

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.92%. Comparing base (8691010) to head (30a68ca).

Files with missing lines Patch % Lines
src/plugins/data/public/search/search_service.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8368      +/-   ##
==========================================
- Coverage   60.92%   60.92%   -0.01%     
==========================================
  Files        3749     3749              
  Lines       89021    89021              
  Branches    13899    13899              
==========================================
- Hits        54236    54234       -2     
- Misses      31423    31424       +1     
- Partials     3362     3363       +1     
Flag Coverage Δ
Linux_1 28.85% <0.00%> (ø)
Linux_2 56.35% <ø> (ø)
Linux_3 37.75% <0.00%> (?)
Linux_4 29.94% <0.00%> (ø)
Windows_1 28.87% <0.00%> (ø)
Windows_2 56.30% <ø> (ø)
Windows_3 37.76% <0.00%> (-0.01%) ⬇️
Windows_4 29.94% <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.

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.

1 participant