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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

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.95%. Comparing base (db7d354) to head (7687fc5).
Report is 24 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.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     
Flag Coverage Δ
Linux_1 28.96% <0.00%> (+0.06%) ⬆️
Linux_2 56.30% <ø> (-0.06%) ⬇️
Linux_3 37.78% <73.33%> (-0.01%) ⬇️
Linux_4 29.92% <0.00%> (-0.04%) ⬇️
Windows_1 28.97% <0.00%> (+0.06%) ⬆️
Windows_2 56.25% <ø> (-0.06%) ⬇️
Windows_3 37.78% <73.33%> (-0.01%) ⬇️
Windows_4 29.92% <0.00%> (-0.04%) ⬇️

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?

opensearch-changeset-bot bot added a commit to sejli/OpenSearch-Dashboards that referenced this pull request Sep 21, 2024
kavilla
kavilla previously approved these changes Sep 23, 2024
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.

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.

5 participants