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] Display Cache Time and Clear Cache Button #8214

Merged
merged 6 commits into from
Oct 1, 2024

Conversation

sejli
Copy link
Member

@sejli sejli commented Sep 18, 2024

Description

  • Stores last cache updated time in session storage. Last updated time refers to the last time that the cache was updated across all datasets (overall cache rather than specific types).
  • Adds display for last cache update time in Advanced Dataset Selector
  • Adds refresh cache button which clears session storage

Still early implementation, open to suggestions

Issues Resolved

Screenshot

Empty Cache State:

image

Cache has been populated:

image

Testing the changes

Changelog

  • feat: Add last updated time and cache refresh button to Discover Advanced Dataset 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

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.98%. Comparing base (d1caa92) to head (b4933c0).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...ry/query_string/dataset_service/dataset_service.ts 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8214      +/-   ##
==========================================
- Coverage   60.98%   60.98%   -0.01%     
==========================================
  Files        3743     3743              
  Lines       88857    88862       +5     
  Branches    13859    13860       +1     
==========================================
+ Hits        54188    54190       +2     
- Misses      31314    31315       +1     
- Partials     3355     3357       +2     
Flag Coverage Δ
Linux_1 28.85% <0.00%> (-0.01%) ⬇️
Linux_2 56.34% <0.00%> (-0.01%) ⬇️
Linux_3 37.79% <80.00%> (+<0.01%) ⬆️
Linux_4 29.94% <0.00%> (-0.01%) ⬇️
Windows_1 28.86% <0.00%> (-0.01%) ⬇️
Windows_2 56.29% <0.00%> (-0.01%) ⬇️
Windows_3 37.79% <80.00%> (+<0.01%) ⬆️
Windows_4 29.94% <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.

@sejli sejli added backport 2.x discover for discover reinvent 2.17.1 labels Sep 18, 2024
Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

should we add tests for new methods + snapshot test to bump up patch cov?

@kavilla
Copy link
Member

kavilla commented Sep 18, 2024

a good catch all but did we want to consider making it more granular?

for example:
Screenshot 2024-09-18 at 3 26 56 PM

if i press the refresh on Data then it clears out the full cache. If i press refresh on Database then it will refresh all the Databases and Tables and not the Connections and Data Sources?

This way to avoid destroying the cache if only one source is out of date?

If so then we can consider extending this function https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data/public/query/query_string/dataset_service/dataset_service.ts#L91 to have a new boolean as a param like refresh = false but if the user presses the refresh button it will clear the cache related to the data structure passed in and it's children and refetch.

To get the date we could actually shove that in the data structure meta for when it was first fetched.

Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

+1 to @virajsanghvi comments. nothing blocking

this.sessionStorage.clear();
}

public getLastCacheTime(): number | undefined {
Copy link
Member

Choose a reason for hiding this comment

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

nit i think there is precedent with updatedAt

kavilla
kavilla previously approved these changes Sep 21, 2024
Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

agreeing with @virajsanghvi with some snapshots will be awesome.

one nit with the naming of the field

one fast follow we should do is pull from ui settings for the date format

@ashwin-pc ashwin-pc merged commit a7f3e9d into opensearch-project:main Oct 1, 2024
69 of 71 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 1, 2024
* initial commit for cache time and clearing cache

Signed-off-by: Sean Li <[email protected]>

* Changeset file for PR #8214 created/updated

* updating UI to address some comments

Signed-off-by: Sean Li <[email protected]>

* addressing comments, adding tests

Signed-off-by: Sean Li <[email protected]>

* removing dynamic default message, following i18n best practice

Signed-off-by: Sean Li <[email protected]>

---------

Signed-off-by: Sean Li <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit a7f3e9d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kavilla pushed a commit that referenced this pull request Oct 2, 2024
* initial commit for cache time and clearing cache



* Changeset file for PR #8214 created/updated

* updating UI to address some comments



* addressing comments, adding tests



* removing dynamic default message, following i18n best practice



---------



(cherry picked from commit a7f3e9d)

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
SuZhou-Joe pushed a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this pull request Oct 3, 2024
…ect#8214) (opensearch-project#8421)

* initial commit for cache time and clearing cache



* Changeset file for PR opensearch-project#8214 created/updated

* updating UI to address some comments



* addressing comments, adding tests



* removing dynamic default message, following i18n best practice



---------



(cherry picked from commit a7f3e9d)

Signed-off-by: Sean Li <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.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