Skip to content

Commit

Permalink
fixing based on last review
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Feb 13, 2017
1 parent b043ce1 commit 8b321d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/ui/public/agg_types/metrics/derivative.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function AggTypeMetricDerivativeProvider(Private) {
return this.makeAgg(agg, state);
},
makeAgg: function (termsAgg, state) {
state = state || {};
state = state || { type: 'count' };
state.schema = orderAggSchema;
const orderAgg = new AggConfig(termsAgg.vis, state);
orderAgg.id = termsAgg.id + '-orderAgg';
Expand All @@ -53,6 +53,7 @@ export default function AggTypeMetricDerivativeProvider(Private) {
{
name: 'metricAgg',
editor: orderAggTemplate,
default: 'custom',
controller: parentPipelineAggController,
write: parentPipelineAggWritter
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const aggFilter = ['!top_hits', '!percentiles', '!percentile_ranks', '!median', '!std_dev'];

const parentPipelineAggController = function ($scope) {

$scope.safeMakeLabel = function (agg) {
Expand All @@ -19,11 +17,9 @@ const parentPipelineAggController = function ($scope) {
}
});

// Returns true if the agg is not compatible with the terms bucket
$scope.rejectAgg = function (agg) {
// aggFilter elements all starts with a '!'
// so the index of agg.type.name in a filter is 1 if it is included
return Boolean(aggFilter.find((filter) => filter.indexOf(agg.type.name) === 1));
const invalidAggs = ['top_hits', 'percentiles', 'percentile_ranks', 'median', 'std_dev'];
return Boolean(invalidAggs.find(invalidAgg => invalidAgg === agg.type.name));
};

function checkBuckets() {
Expand Down Expand Up @@ -52,6 +48,9 @@ const parentPipelineAggController = function ($scope) {

// we aren't creating a custom aggConfig
if (metricAgg !== 'custom') {
if (!$scope.vis.aggs.find(agg => agg.id === metricAgg)) {
params.metricAgg = null;
}
params.customMetric = null;
return;
}
Expand Down

0 comments on commit 8b321d6

Please sign in to comment.