Added aggregation functions processing.

This commit is contained in:
Alexander Zobnin
2016-01-27 23:19:27 +03:00
parent 14e55fcbf0
commit 0680f65370
3 changed files with 64 additions and 9 deletions

View File

@@ -2,10 +2,9 @@ define([
'angular',
'lodash',
'moment',
'./utils',
'./metricFunctions'
'./utils'
],
function (angular, _, moment, utils, metricFunctions) {
function (angular, _, moment, utils) {
'use strict';
var module = angular.module('grafana.services');
@@ -118,8 +117,16 @@ function (angular, _, moment, utils, metricFunctions) {
return self.groupBy(interval, groupByCallback, datapoints);
};
this.aggregateWrapper = function(groupByCallback, interval, datapoints) {
var flattenedPoints = _.flatten(datapoints, true);
return self.groupBy(interval, groupByCallback, flattenedPoints);
};
this.metricFunctions = {
groupBy: this.groupByWrapper,
average: _.partial(this.aggregateWrapper, this.AVERAGE),
min: _.partial(this.aggregateWrapper, this.MIN),
max: _.partial(this.aggregateWrapper, this.MAX),
};
});