[Discover] Remove redundant execution of onRequestStart when fetching data (#94093)

This commit is contained in:
Matthias Wilhelm 2021-03-16 17:34:24 +01:00 committed by GitHub
parent 067543b51b
commit d71e1b47af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -700,7 +700,13 @@ function discoverController($route, $scope, Promise) {
async function setupVisualization() {
// If no timefield has been specified we don't create a histogram of messages
if (!getTimeField() || $scope.state.hideChart) return;
if (!getTimeField() || $scope.state.hideChart) {
if ($scope.volatileSearchSource.getField('aggs')) {
// cleanup aggs field in case it was set before
$scope.volatileSearchSource.removeField('aggs');
}
return;
}
const { interval: histogramInterval } = $scope.state;
const visStateAggs = [
@ -723,11 +729,6 @@ function discoverController($route, $scope, Promise) {
visStateAggs
);
$scope.volatileSearchSource.onRequestStart((searchSource, options) => {
if (!$scope.opts.chartAggConfigs) return;
return $scope.opts.chartAggConfigs.onSearchRequestStart(searchSource, options);
});
$scope.volatileSearchSource.setField('aggs', function () {
if (!$scope.opts.chartAggConfigs) return;
return $scope.opts.chartAggConfigs.toDsl();