-
Notifications
You must be signed in to change notification settings - Fork 871
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
base: main
Are you sure you want to change the base?
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.95% 60.95%
=======================================
Files 3758 3766 +8
Lines 89288 89385 +97
Branches 13970 13982 +12
=======================================
+ Hits 54422 54488 +66
- Misses 31478 31499 +21
- Partials 3388 3398 +10
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
src/plugins/data/public/ui/dataset_selector/dataset_selector.tsx
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/ui/dataset_selector/dataset_selector.tsx
Outdated
Show resolved
Hide resolved
7b188aa
to
18d458d
Compare
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 <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
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