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] Adding Recent Datasets #8133

Merged
merged 13 commits into from
Oct 11, 2024
Merged

Conversation

sejli
Copy link
Member

@sejli sejli commented Sep 11, 2024

Description

Adds recent datasets to dataset selector. Also fixes an issue where we were able to select an index without specifying a time field option.

image image

Issues Resolved

Screenshot

Testing the changes

Changelog

  • feat: Adds recently selected data to data 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

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 11, 2024

Codecov Report

Attention: Patch coverage is 73.33333% with 8 lines in your changes missing coverage. Please review.

Project coverage is 60.94%. Comparing base (3ae4cdc) to head (d071b25).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
...ta/public/ui/dataset_selector/dataset_selector.tsx 58.82% 6 Missing and 1 partial ⚠️
...ry/query_string/dataset_service/dataset_service.ts 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8133   +/-   ##
=======================================
  Coverage   60.93%   60.94%           
=======================================
  Files        3767     3767           
  Lines       89413    89434   +21     
  Branches    13998    14002    +4     
=======================================
+ Hits        54485    54505   +20     
  Misses      31525    31525           
- Partials     3403     3404    +1     
Flag Coverage Δ
Linux_1 28.95% <0.00%> (-0.01%) ⬇️
Linux_2 56.25% <ø> (ø)
Linux_3 37.77% <73.33%> (+0.01%) ⬆️
Linux_4 29.91% <0.00%> (-0.01%) ⬇️
Windows_1 28.97% <0.00%> (-0.01%) ⬇️
Windows_2 56.20% <ø> (ø)
Windows_3 37.77% <73.33%> (+0.01%) ⬆️
Windows_4 29.91% <0.00%> (-0.01%) ⬇️

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.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Nice! Can we add some tests for this feature so that we can be sure that these dont break as we fix more things?

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Lemme know what you think about my comments on:

  1. Caching the recent datasets in the session storage
  2. Adding to recent datasets when the query in the query string manager is updated

@@ -31,6 +33,9 @@ export class DatasetService {
if (this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED)) {
this.registerDefaultTypes();
}
this.recentDatasets = new LRUCache({
Copy link
Member

Choose a reason for hiding this comment

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

We should store this in session storage so that when the user returns we can show them this. Not a blocker for this PR, but if we are skipping this, lets add a fast follow. Recent datasets are not very useful if they dont persist across my session

Copy link
Member

Choose a reason for hiding this comment

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

+1

yeah I agree i think sean and i had similar idea. we should def backlog an item posting.

copy pasta for transparency:


in the interest of timelines, potential approach use hook for setRecentDatasets and then a new const recentOptions to useMemo and then join the the options in the html component

  • create backlog issue: storing the datasets created in the dataset service
    • new function in dataset service like getDatasets()
    • populate the selector for all the datasets. when users create a dataset it stores the dataset service and updates the LRU recent datasets. when user select a dataset it will update the LRU recent datasets.
    • can use the session storage to store datasets since it data structure could be of type DATASET.
    • when the user opens the dataset selector for the first time it calls getRecentDatasets and and getDatasets from the data service. then subsequent calls will just be the get recent datasets.
  • benefits: dataset service is a single source of truth of recent datasets and datasets. another plugin can access the datasets without using our component. we can easily update the session id in the dataset service without the query state being updated.

return Array.from(this.recentDatasets.values());
}

public addRecentDataset(dataset: Dataset | undefined): void {
Copy link
Member

Choose a reason for hiding this comment

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

+1 Again not a blocker for this PR, but we should add a fast follow to do this automatically when a dataset is set in the query manager. additionally if we dont want certain setQuery.dataset calls to update the LRU cache, we can always pass a option to not cache it. This can be used for on page load updates that load the default dataset on page load if no dataset is present in the URL.

This will be a source of bugs in the future when someone in another app or usecase forgets to call this.

joshuali925
joshuali925 previously approved these changes Oct 8, 2024
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: Sean Li <lnse@amazon.com>
@sejli sejli merged commit 464ef56 into opensearch-project:main Oct 11, 2024
69 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 11, 2024
* Adding recent datasets to dataset selector

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

* addressing comments, adding tests

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

* moving recent datasets to fetched datasets

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

* mocking UI settings for test

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

* fixing connect_to_query_state.test

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

* fixing sync_state_with_url test

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

* adding recent datasets to session storage

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

* fixing cache bug, improving code structure

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

* adding i18n translation for group labels

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

* updating mock

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

* updating state sync tests and fixing typos in #8325

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

* fixing dataset selector test

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

* fixing index test

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

---------

Signed-off-by: Sean Li <lnse@amazon.com>
(cherry picked from commit 464ef56)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
sejli pushed a commit that referenced this pull request Oct 15, 2024
sejli added a commit to sejli/OpenSearch-Dashboards that referenced this pull request Oct 21, 2024
* Adding recent datasets to dataset selector

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

* addressing comments, adding tests

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

* moving recent datasets to fetched datasets

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

* mocking UI settings for test

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

* fixing connect_to_query_state.test

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

* fixing sync_state_with_url test

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

* adding recent datasets to session storage

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

* fixing cache bug, improving code structure

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

* adding i18n translation for group labels

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

* updating mock

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

* updating state sync tests and fixing typos in opensearch-project#8325

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

* fixing dataset selector test

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

* fixing index test

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

---------

Signed-off-by: Sean Li <lnse@amazon.com>
Qxisylolo pushed a commit to Qxisylolo/OpenSearch-Dashboards that referenced this pull request Oct 30, 2024
* Adding recent datasets to dataset selector

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

* addressing comments, adding tests

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

* moving recent datasets to fetched datasets

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

* mocking UI settings for test

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

* fixing connect_to_query_state.test

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

* fixing sync_state_with_url test

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

* adding recent datasets to session storage

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

* fixing cache bug, improving code structure

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

* adding i18n translation for group labels

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

* updating mock

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

* updating state sync tests and fixing typos in opensearch-project#8325

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

* fixing dataset selector test

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

* fixing index test

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

---------

Signed-off-by: Sean Li <lnse@amazon.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