-
Notifications
You must be signed in to change notification settings - Fork 893
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
Conversation
❌ Empty Changelog SectionThe 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. |
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Nice! Can we add some tests for this feature so that we can be sure that these dont break as we fix more things?
src/plugins/data/public/query/query_string/dataset_service/dataset_service.ts
Show resolved
Hide resolved
src/plugins/data/public/query/query_string/dataset_service/dataset_service.ts
Outdated
Show resolved
Hide resolved
src/plugins/data/public/query/query_string/dataset_service/dataset_service.ts
Show resolved
Hide resolved
src/plugins/data/public/query/query_string/dataset_service/dataset_service.ts
Show resolved
Hide resolved
src/plugins/data/public/ui/dataset_selector/dataset_selector.tsx
Outdated
Show resolved
Hide resolved
src/plugins/data/public/ui/dataset_selector/dataset_selector.tsx
Outdated
Show resolved
Hide resolved
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.
Lemme know what you think about my comments on:
- Caching the recent datasets in the session storage
- 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({ |
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.
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
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.
+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.
- new function in dataset service like
- 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 { |
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.
+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.
src/plugins/data/public/ui/dataset_selector/dataset_selector.tsx
Outdated
Show resolved
Hide resolved
src/plugins/data/public/ui/dataset_selector/dataset_selector.tsx
Outdated
Show resolved
Hide resolved
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>
Signed-off-by: Sean Li <lnse@amazon.com>
* 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>
* 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>
* 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>
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.
Issues Resolved
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration