Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
[aggConfig] allow mutliple metrics to be written in the DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer Alger committed Nov 15, 2014
1 parent 683970c commit 1ae3713
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/kibana/components/vis/_agg_configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ define(function (require) {
var nestedMetric;

if (this.vis.isHierarchical()) {
// collect the metric agg that we will copy under each bucket agg
var nestedMetricConfig = _.first(this.vis.aggs.bySchemaGroup.metrics);
if (nestedMetricConfig.type.name !== 'count') {
nestedMetric = {
config: nestedMetricConfig,
dsl: nestedMetricConfig.toDsl()
// collect all metrics, and filter out the ones that we won't be copying
var nestedMetrics = _(this.vis.aggs.bySchemaGroup.metrics)
.filter(function (agg) {
return agg.type.name !== 'count';
})
.map(function (agg) {
return {
config: agg,
dsl: agg.toDsl()
};
}
});
}

this.getSorted()
Expand Down Expand Up @@ -84,8 +87,10 @@ define(function (require) {
subAggs = dsl.aggs || (dsl.aggs = {});
}

if (subAggs && nestedMetric) {
subAggs[nestedMetric.config.id] = nestedMetric.dsl;
if (subAggs && nestedMetrics) {
nestedMetrics.forEach(function (agg) {
subAggs[agg.config.id] = agg.dsl;
});
}
});

Expand Down

0 comments on commit 1ae3713

Please sign in to comment.