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] Fix broken setting of bucketInterval #62939

Original file line number Diff line number Diff line change
Expand Up @@ -675,17 +675,6 @@ function discoverController(
}
});

$scope.$watch('vis.aggs', function() {
Copy link
Member Author

@kertal kertal Apr 8, 2020

Choose a reason for hiding this comment

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

The watcher didn't work due to the Visualizations API changes, decided it's even not needed and removed it in favor of a simpler solution

// no timefield, no vis, nothing to update
if (!getTimeField() || !$scope.vis) return;

const buckets = $scope.vis.data.aggs.byTypeName('buckets');

if (buckets && buckets.length === 1) {
$scope.bucketInterval = buckets[0].buckets.getInterval();
}
});

$scope.$watchMulti(
['rows', 'fetchStatus'],
(function updateResultState() {
Expand Down Expand Up @@ -891,6 +880,9 @@ function discoverController(
tabifiedData,
getDimensions($scope.vis.data.aggs.aggs, $scope.timeRange)
);
if ($scope.vis.data.aggs.aggs[1]) {
$scope.bucketInterval = $scope.vis.data.aggs.aggs[1].buckets.getInterval();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

dear @ppisljar, this API changed. This works, but I wonder if there's a better way to do it. Before it was done this way:

      const buckets = $scope.vis.data.aggs.byTypeName('buckets');		

          if (buckets && buckets.length === 1) {		
           $scope.bucketInterval = buckets[0].buckets.getInterval();		
         }

}

$scope.hits = resp.hits.total;
Expand Down