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 too many queries sent #8347

Merged

Conversation

kavilla
Copy link
Member

@kavilla kavilla commented Sep 25, 2024

Description

Fixes the issue where too many queries were being fired. A number of things were being called because the dependency array was triggering updates and re-calls. Forcing a re-render of elements that had the possibility of updating the query manager.

Includes some tests.

Issues Resolved

n/a

Screenshot

Testing the changes

locally and tests

Changelog

  • fix: prevent too many queries sent from dataset selector

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

the dependency array was triggering updates and re-calls. forcing a re-render
of elements that had the possibility of updating the query manager.

Signed-off-by: Kawika Avilla <kavilla414@gmail.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

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 62.50000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 60.92%. Comparing base (d1caa92) to head (3352f97).
Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
...ta/public/ui/dataset_selector/dataset_selector.tsx 53.33% 3 Missing and 4 partials ⚠️
.../plugins/data/public/ui/dataset_selector/index.tsx 87.50% 0 Missing and 1 partial ⚠️
...tion/view_components/utils/update_search_source.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8347      +/-   ##
==========================================
- Coverage   60.98%   60.92%   -0.07%     
==========================================
  Files        3743     3748       +5     
  Lines       88857    89016     +159     
  Branches    13859    13898      +39     
==========================================
+ Hits        54188    54229      +41     
- Misses      31314    31424     +110     
- Partials     3355     3363       +8     
Flag Coverage Δ
Linux_1 28.85% <0.00%> (+<0.01%) ⬆️
Linux_2 56.34% <ø> (ø)
Linux_3 ?
Linux_4 29.94% <ø> (ø)
Windows_1 28.87% <0.00%> (+<0.01%) ⬆️
Windows_2 56.29% <ø> (ø)
Windows_3 37.76% <62.50%> (-0.04%) ⬇️
Windows_4 29.94% <ø> (ø)

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: Kawika Avilla <kavilla414@gmail.com>
Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
abbyhu2000
abbyhu2000 previously approved these changes Sep 26, 2024
sejli
sejli previously approved these changes Sep 26, 2024
Copy link
Member

@sejli sejli left a comment

Choose a reason for hiding this comment

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

Amazing

Comment on lines -23 to -29
useEffect(() => {
const subscription = queryString.getUpdates$().subscribe((query) => {
setSelectedDataset(query.dataset);
});

return () => subscription.unsubscribe();
}, [queryString]);
Copy link
Member

Choose a reason for hiding this comment

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

I remember being confused why this is here. Was there a reason why we needed two places to set the selected dataset?

Copy link
Member Author

Choose a reason for hiding this comment

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

not positive. probably was just code that was intended to be cleaned up i think i at one point we would set the query at the configurator level instead of using the function that we passed in to set it and then when we got time to wire up and use the passed in function it caused some issue with re-rendering.

@@ -68,6 +68,7 @@ export class QueryStringManager {
const query = {
query: defaultQuery,
language: defaultLanguageId,
dataset: undefined,
Copy link
Member

Choose a reason for hiding this comment

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

why is this necessary? i see query is used to construct newQuery and dataset is set to be defaultDataset in line 81

Copy link
Member Author

@kavilla kavilla Sep 26, 2024

Choose a reason for hiding this comment

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

my linter was complaining because i thought the return type was just query language but it's causing a test failure so im just gunna revert this and but a linter ignore

joshuali925
joshuali925 previously approved these changes Sep 26, 2024
Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

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

nice, lgtm

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
…OpenSearch-Dashboards-1 into kavilla/discovermultiplequeries
@kavilla kavilla dismissed stale reviews from joshuali925, sejli, and abbyhu2000 via 3352f97 September 26, 2024 22:32
@kavilla kavilla merged commit 0882435 into opensearch-project:main Sep 26, 2024
63 of 67 checks passed
@kavilla
Copy link
Member Author

kavilla commented Sep 26, 2024

failures unrelated and i think another PR is fixing it.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 26, 2024
Fixes the issue where too many queries were being fired. A number of things were being called because the dependency array was triggering updates and re-calls. Forcing a re-render of elements that had the possibility of updating the query manager.

Includes some tests.

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

---------

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 0882435)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ps48 pushed a commit to ps48/OpenSearch-Dashboards that referenced this pull request Sep 27, 2024
Fixes the issue where too many queries were being fired. A number of things were being called because the dependency array was triggering updates and re-calls. Forcing a re-render of elements that had the possibility of updating the query manager.

Includes some tests.

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>

---------

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
ashwin-pc pushed a commit that referenced this pull request Sep 27, 2024
Fixes the issue where too many queries were being fired. A number of things were being called because the dependency array was triggering updates and re-calls. Forcing a re-render of elements that had the possibility of updating the query manager.

Includes some tests.



---------



(cherry picked from commit 0882435)

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
SuZhou-Joe pushed a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this pull request Oct 3, 2024
…earch-project#8361)

Fixes the issue where too many queries were being fired. A number of things were being called because the dependency array was triggering updates and re-calls. Forcing a re-render of elements that had the possibility of updating the query manager.

Includes some tests.



---------



(cherry picked from commit 0882435)

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
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.

6 participants