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

Fix duplicate fetch in Visualize #41204

Merged
merged 11 commits into from
Aug 8, 2019

Conversation

lukasolson
Copy link
Member

Summary

Fixes the behavior in Visualize that refreshing causes multiple search requests.

Prior to this PR, navigating to Visualize and creating a visualization, then hitting refresh (or modifying the query in some manner) would cause multiple requests to be fired off. This PR fixes it by only firing off a fetch request manually when nothing has changed, and otherwise relying on the behavior of visualizations to cause fetches in response to changes within their state.

Here's a GIF showing the behavior beforehand:

Jul-15-2019 14-49-41

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@lukeelmers
Copy link
Member

This overlaps some with this PR from Joe: #41144
// cc @flash1293

Maybe it would be good to combine these efforts since they are solving different parts of the same problem

@flash1293
Copy link
Contributor

@lukeelmers Suggestion: I will exclude the editor from my changes and we solve the disabled filters thing in the editor as a part of this PR.

@lukeelmers
Copy link
Member

@flash1293 That makes sense to me if it makes sense to @lukasolson :)

@lukasolson
Copy link
Member Author

@lukeelmers @flash1293 Sounds good, I'll update this PR.

@lukasolson lukasolson force-pushed the noDuplicateFetches branch from 57cfa68 to dcd2662 Compare July 24, 2019 22:46
@lukasolson
Copy link
Member Author

This is ready for another review.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@lukasolson
Copy link
Member Author

After talking with @lizozom, I have a couple of fixes to make on this PR, so hold off on review.

@lukasolson lukasolson force-pushed the noDuplicateFetches branch from dcd2662 to a618a3e Compare July 29, 2019 23:33
@lukasolson
Copy link
Member Author

@lizozom Could you take another look at this PR?

@lukasolson lukasolson requested a review from lizozom July 29, 2019 23:36
@elasticmachine
Copy link
Contributor

💔 Build Failed

$scope.$watchGroup(['timeRange', 'filters'], debounce(() => {
$scope.renderFunction();
}, 100));
$scope.$watch('timeRange', debounce($scope.renderFunction, 100));
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay.
But will anything else call renderFunction now?

@lukasolson lukasolson requested a review from lizozom August 2, 2019 23:49
@elasticmachine
Copy link
Contributor

💔 Build Failed

(dateRange && !_.isEqual(dateRange, $scope.timeRange))
);

if (query && !_.isEqual(query, $state.query)) $state.query = query;
Copy link
Member

Choose a reason for hiding this comment

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

do we still need this checks here if w have the checks in embedded_visualize_handler ?

Copy link
Member Author

Choose a reason for hiding this comment

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

We still need to check if nothing has changed in order to manually trigger a fetch, but you're right, we don't need to check before we set them. Fixed in cc10e25.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

LGTM, tested in chrome linux

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@lukasolson lukasolson merged commit fc1ea0b into elastic:master Aug 8, 2019
lukasolson added a commit to lukasolson/kibana that referenced this pull request Aug 8, 2019
* Fix duplicate fetch in Visualize

* Don't refetch when disabled filters change

* Use query filter fetches observable

* Add back in watch on filters

* Revert change completely

* Update test to include non-disabled filter

* Remove unnecessary checks
@lukasolson
Copy link
Member Author

7.x (7.4.0): 59c1eb9

jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 9, 2019
…p-metrics-selectall

* 'master' of github.com:elastic/kibana: (306 commits)
  [ML] Adding job overrides to the module setup endpoint (elastic#42946)
  [APM] Fix missing RUM url (elastic#42940)
  close socket timeouts without message (elastic#42456)
  Upgrade elastic/charts to 8.1.6 (elastic#42518)
  [ML] Delete old AngularJS data visualizer and refactor folders (elastic#42962)
  Add custom formatting for Date Nanos Format (elastic#42445)
  [Vega] Shim new platform - vega_fn.js -> vega_fn.js , use ExpressionFunction (elastic#42582)
  add socket.getPeerCertificate to KibanaRequest (elastic#42929)
  [Automation] ISTANBUL PRESET PATH is not working fine with constructor(private foo) (elastic#42683)
  [ML] Data frames: Updated stats structure. (elastic#42923)
  [Code] fixed the issue that the repository can not be deleted in some cases. (elastic#42841)
  [kbn-es] Support for passing regex value to ES (elastic#42651)
  Connect to Elasticsearch via SSL when starting kibana with `--ssl` (elastic#42840)
  Add Elasticsearch SSL support for integration tests (elastic#41765)
  Fix duplicate fetch in Visualize (elastic#41204)
  [DOCS] TSVB and Timelion clean up (elastic#42953)
  [Maps] [File upload] Fix maps geojson upload hanging on index step (elastic#42623)
  [APM] Use rounded bucket sizes for transaction distribution (elastic#42830)
  [yarn.lock] consistent resolve domain (elastic#42969)
  [Uptime] [Test] Repurpose unit test assertions to avoid flakiness (elastic#40650)
  ...
@lukasolson lukasolson deleted the noDuplicateFetches branch December 2, 2019 22:35
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