Commit 139b19f9 by carl bergquist

feat(elasticsearch): make series naming generic for pipeline aggs

parent 6e50e241
......@@ -197,7 +197,7 @@ function (_, queryDef) {
});
}
if (series.field && series.metric === 'moving_avg') {
if (series.field && queryDef.isPipelineAgg(series.metric)) {
var appliedAgg = _.findWhere(target.metrics, { id: series.field });
if (appliedAgg) {
metricName += ' ' + queryDef.describeMetric(appliedAgg);
......
......@@ -37,7 +37,7 @@ function (angular, _, queryDef) {
$scope.settingsLinkText = '';
$scope.aggDef = _.findWhere($scope.metricAggTypes, {value: $scope.agg.type});
if (queryDef.isPipelineAgg($scope.agg)) {
if (queryDef.isPipelineAgg($scope.agg.type)) {
$scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric';
$scope.agg.field = $scope.agg.pipelineAgg;
$scope.settingsLinkText = 'Options';
......
......@@ -171,7 +171,7 @@ function (queryDef) {
var aggField = {};
var metricAgg = null;
if (queryDef.isPipelineAgg(metric)) {
if (queryDef.isPipelineAgg(metric.type)) {
if (metric.pipelineAgg && /^\d*$/.test(metric.pipelineAgg)) {
metricAgg = { buckets_path: metric.pipelineAgg };
} else {
......
......@@ -76,16 +76,16 @@ function (_) {
},
getPipelineOptions: function(metric) {
if (!this.isPipelineAgg(metric)) {
if (!this.isPipelineAgg(metric.type)) {
return [];
}
return this.pipelineOptions[metric.type];
},
isPipelineAgg: function(metric) {
if (metric.type) {
var po = this.pipelineOptions[metric.type];
isPipelineAgg: function(metricType) {
if (metricType) {
var po = this.pipelineOptions[metricType];
return po !== null && po !== undefined;
}
......@@ -96,7 +96,7 @@ function (_) {
var self = this;
var result = [];
_.each(targets.metrics, function(metric) {
if (!self.isPipelineAgg(metric)) {
if (!self.isPipelineAgg(metric.type)) {
result.push({text: self.describeMetric(metric), value: metric.id });
}
});
......
......@@ -64,7 +64,7 @@ describe('ElasticQueryDef', function() {
describe('isPipelineMetric', function() {
describe('moving_avg', function() {
var result = QueryDef.isPipelineAgg({ type: 'moving_avg' });
var result = QueryDef.isPipelineAgg('moving_avg');
it('is pipe line metric', function() {
expect(result).to.be(true);
......@@ -72,7 +72,7 @@ describe('ElasticQueryDef', function() {
});
describe('count', function() {
var result = QueryDef.isPipelineAgg({ type: 'count' });
var result = QueryDef.isPipelineAgg('count');
it('is not pipe line metric', function() {
expect(result).to.be(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment