-
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.98% 60.98% -0.01%
==========================================
Files 3743 3743
Lines 88857 88863 +6
Branches 13859 13861 +2
==========================================
+ Hits 54188 54190 +2
- Misses 31314 31315 +1
- Partials 3355 3358 +3
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
How are you limiting the recents? |
src/plugins/data/public/ui/dataset_selector/dataset_selector.tsx
Outdated
Show resolved
Hide resolved
@@ -34,6 +35,7 @@ const ConnectedDatasetSelector = ({ onSubmit }: ConnectedDatasetSelectorProps) = | |||
const query = queryString.getInitialQueryByDataset(dataset); | |||
queryString.setQuery(query); | |||
onSubmit!(queryString.getQuery()); | |||
services.data.query.queryString.getDatasetService().addRecentDataset(dataset); |
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.
queryString.getDatasetService().addRecentDataset(initialDataset);
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.
@ashwin-pc do you think we should be just handling this is the query string manager? like updating the recents based on the query?
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.
Yes that would make it less prone to issues like when datasets are selected using ways that arent the dataset selector. Wouldnt block on that being a requirement, but that is a cleaner approach
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.
@sejli maybe could be an open issue
@@ -31,6 +33,9 @@ export class DatasetService { | |||
if (this.uiSettings.get(UI_SETTINGS.QUERY_ENHANCEMENTS_ENABLED)) { | |||
this.registerDefaultTypes(); | |||
} | |||
this.recentDatasets = new LRUCache({ | |||
max: this.uiSettings.get(UI_SETTINGS.SEARCH_MAX_RECENT_DATASETS) ?? 4, |
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.
nit: could this actually be undefined?
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.
While running tests, uiSettings
has everything set to be jest.fn()
, which is the only place where it would be undefined. Could override the original uiSettings
mock such that uiSettings.get()
returns 4
, would that be better practice?
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.
yes, dont change the UI implementation to meet a test infrastructure gap if possible.
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.
do you think instead of relying on the UI component for setting the dataset the recent dataset is the one that is used? so like nobody could add recent dataset they can only access the recent data sets?
@@ -165,6 +165,7 @@ export const Configurator = ({ | |||
onConfirm(dataset); | |||
}} | |||
fill | |||
disabled={timeFields && timeFields.length > 0 && timeFieldName === undefined} |
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.
nit: but couldn't you combine the first two expressions down to timeFields?.length > 0
.
do you think that the way you did it would be better style?
setSelectedDataset( | ||
allDatasets.filter((ds) => ds.recent)[0].dataset ?? | ||
allDatasets.filter((ds) => !ds.recent)[0].dataset | ||
); |
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.
is the second filter needed? since if there's no recent datasets, then every dataset should satisfy !ds.recent
also recent datasets are added at first anyways, this is just allDatasets[0].dataset
?
@@ -23,6 +24,7 @@ export class DatasetService { | |||
private indexPatterns?: IndexPatternsContract; | |||
private defaultDataset?: Dataset; | |||
private typesRegistry: Map<string, DatasetTypeConfig> = new Map(); | |||
private recentDatasets: LRUCache<string, Dataset>; |
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.
is this just in memory or stored in some storage?
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.
Currently, we'll just store it in memory.
(dataset) => !recentDatasets.some((ds) => ds.id === dataset.id) | ||
); | ||
const allDatasets = [ | ||
...recentDatasets.map((ds) => ({ dataset: ds, recent: true })), |
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.
would there be invalid/outdated datasets? should we check and make sure every recent dataset appears in the fetchedDatasets?
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>
7b188aa
to
18d458d
Compare
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