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] Disable refresh interval for data views without time fields and rollups #137134

Merged
merged 5 commits into from
Jul 27, 2022

Conversation

davismcphee
Copy link
Contributor

@davismcphee davismcphee commented Jul 26, 2022

Summary

This PR fixes an issue where the auto refresh interval continues to run after switching to a data view without time fields even though the date picker is hidden. This means there is no way to disable the refresh interval except by switching back to a data view with a time field. Now the refresh interval will automatically be paused when the date picker is hidden.

auto-refresh

There is also a fix for an issue that was affecting the interval refresh where pressing the back button would update the URL and global state, but the app state and the data view wouldn't update:

data-view-not-updating

Fixes #102132.

Checklist

For maintainers

@davismcphee davismcphee added Feature:Discover Discover Application release_note:fix Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.4.0 labels Jul 26, 2022
@davismcphee davismcphee self-assigned this Jul 26, 2022
@@ -293,6 +312,8 @@ export function getState({
stateStorage
);

const { start, stop } = syncAppState();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calling syncState from within initializeAndSync fixes the back button state issue. This is because syncState takes a snapshot of the initial state to compare against before syncing state updates: https://github.com/elastic/kibana/blob/main/src/plugins/kibana_utils/public/state_sync/state_sync.ts#L151. When syncState is called from outside of initializeAndSync, the snapshot doesn't get reset when the data view is changed. Then when the user presses the back button, the new state appears to be the same as the initial state, so syncState ignores the update. Moving the call to syncState inside of initializeAndSync means the snapshot gets updated each time the data view changes and no state changes are ignored.

Copy link
Member

Choose a reason for hiding this comment

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

Great findings Davis, makes sense. Could you inline a comment how it when syncAppState is executed? best where the function is defined. I think it is helpful for future work, wasn't aware of the fact

@davismcphee davismcphee marked this pull request as ready for review July 27, 2022 03:19
@davismcphee davismcphee requested a review from a team as a code owner July 27, 2022 03:19
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

return {
kbnUrlStateStorage: stateStorage,
appStateContainer: appStateContainerModified,
startSync: start,
stopSync: stop,
startSync: () => {
Copy link
Member

Choose a reason for hiding this comment

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

I just thought, it might be worth to mention here that we just use this function for testing

@kertal kertal requested a review from dimaanj July 27, 2022 10:10
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Thx for fixing this and overall improving this part of our code 👍 Tested locally and works as expected. One ask @dimaanj since this changing a significant part of our URL state, could you double check? thx

@davismcphee davismcphee force-pushed the fix-discover-refresh-interval branch from bf85afc to 6495774 Compare July 27, 2022 14:26
Copy link
Contributor

@dimaanj dimaanj left a comment

Choose a reason for hiding this comment

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

Tested locally, LGTM.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 500.5KB 501.1KB +624.0B

History

  • 💛 Build #60971 was flaky bf85afc9cc9cbe8716a399fd9045e72284db1795
  • 💚 Build #60660 succeeded cf6d05273756b53ea5e2a5c2317926173e0bb19a

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @davismcphee

@davismcphee davismcphee merged commit 998b11a into elastic:main Jul 27, 2022
@davismcphee davismcphee deleted the fix-discover-refresh-interval branch July 27, 2022 16:38
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 27, 2022
…s and rollups (elastic#137134)

* [Discover] Fix refresh interval running for non time series data

* [Discover] Clean up disable auto refresh interval code, and fix issue where going back and forward through history was not updating data view

* [Discover] Clean up discover_state tests

* [Discover] Add tests for disable auto refresh

* [Discover] Add comments for state syncing code

(cherry picked from commit 998b11a)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.4

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 28, 2022
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

kibanamachine added a commit that referenced this pull request Jul 29, 2022
…s and rollups (#137134) (#137316)

* [Discover] Fix refresh interval running for non time series data

* [Discover] Clean up disable auto refresh interval code, and fix issue where going back and forward through history was not updating data view

* [Discover] Clean up discover_state tests

* [Discover] Add tests for disable auto refresh

* [Discover] Add comments for state syncing code

(cherry picked from commit 998b11a)

Co-authored-by: Davis McPhee <[email protected]>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application release_note:fix Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.4.0 v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discover] Refresh interval hidden in non time series data sets
6 participants