Fix percentile() function, closes #862 (#863)

Like the other aggregation functions, the datapoints need to be sorted in
time before calling groupBy_perf().
This commit is contained in:
Mark Reibert
2020-01-11 10:28:32 -07:00
committed by Alexander Zobnin
parent d54d6d29dc
commit dd28b28174

View File

@@ -121,9 +121,11 @@ function aggregateWrapper(groupByCallback, interval, datapoints) {
}
function percentile(interval, n, datapoints) {
var flattenedPoints = ts.flattenDatapoints(datapoints);
var groupByCallback = _.partial(PERCENTILE, n);
return groupBy(flattenedPoints, interval, groupByCallback);
const flattenedPoints = ts.flattenDatapoints(datapoints);
// groupBy_perf works with sorted series only
const sortedPoints = ts.sortByTime(flattenedPoints);
let groupByCallback = _.partial(PERCENTILE, n);
return groupBy(sortedPoints, interval, groupByCallback);
}
function timeShift(interval, range) {