fix multiple agg functions handling, closes #530

This commit is contained in:
Alexander Zobnin
2019-03-07 10:35:36 +03:00
parent 3428137f7c
commit e4bbecb18b
4 changed files with 52 additions and 4 deletions

View File

@@ -107,7 +107,7 @@ function groupByWrapper(interval, groupFunc, datapoints) {
function aggregateByWrapper(interval, aggregateFunc, datapoints) {
// Flatten all points in frame and then just use groupBy()
const flattenedPoints = _.flatten(datapoints, true);
const flattenedPoints = ts.flattenDatapoints(datapoints);
// groupBy_perf works with sorted series only
const sortedPoints = ts.sortByTime(flattenedPoints);
let groupByCallback = aggregationFunctions[aggregateFunc];
@@ -115,14 +115,14 @@ function aggregateByWrapper(interval, aggregateFunc, datapoints) {
}
function aggregateWrapper(groupByCallback, interval, datapoints) {
var flattenedPoints = _.flatten(datapoints, true);
var flattenedPoints = ts.flattenDatapoints(datapoints);
// groupBy_perf works with sorted series only
const sortedPoints = ts.sortByTime(flattenedPoints);
return groupBy(sortedPoints, interval, groupByCallback);
}
function percentil(interval, n, datapoints) {
var flattenedPoints = _.flatten(datapoints, true);
var flattenedPoints = ts.flattenDatapoints(datapoints);
var groupByCallback = _.partial(PERCENTIL, n);
return groupBy(flattenedPoints, interval, groupByCallback);
}