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

This commit is contained in:
carl bergquist 2015-12-10 17:42:31 +01:00
parent 6e50e2412e
commit 139b19f9ac
5 changed files with 10 additions and 10 deletions

View File

@ -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);

View File

@ -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';

View File

@ -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 {

View File

@ -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 });
}
});

View File

@ -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);