From 6e50e2412e061895aab6e350f2d06a0ce6480e3d Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 10 Dec 2015 17:18:22 +0100 Subject: [PATCH] feat(elasticsearch): remove pipeline aggs as possible sources --- .../datasource/elasticsearch/query_def.js | 2 +- .../elasticsearch/specs/query_def_specs.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index f5f4cc600e4..e84ff00aab9 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -96,7 +96,7 @@ function (_) { var self = this; var result = []; _.each(targets.metrics, function(metric) { - if (metric.type !== 'moving_avg') { + if (!self.isPipelineAgg(metric)) { result.push({text: self.describeMetric(metric), value: metric.id }); } }); diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts index 7f8be653dfc..153639d3d9a 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts @@ -42,10 +42,24 @@ describe('ElasticQueryDef', function() { var response = QueryDef.getPipelineAggOptions(targets); - it('should return zero', function() { + it('should return one', function() { expect(response.length).to.be(1); }); }); + + describe('with derivatives targets', function() { + var targets = { + metrics: [ + { type: 'derivative', field: '@value' } + ] + }; + + var response = QueryDef.getPipelineAggOptions(targets); + + it('should return zero', function() { + expect(response.length).to.be(0); + }); + }); }); describe('isPipelineMetric', function() {