Aggregation functions refactoring.

This commit is contained in:
Alexander Zobnin
2016-01-29 17:30:18 +03:00
parent 2819162809
commit 2676ca246b
2 changed files with 4 additions and 9 deletions

View File

@@ -92,9 +92,9 @@ function (angular, _, moment, utils) {
}); });
// Convert points to Grafana format // Convert points to Grafana format
return _.map(grouped, function(value, timestamp) { return sortByTime(_.map(grouped, function(value, timestamp) {
return [Number(value), Number(timestamp)]; return [Number(value), Number(timestamp)];
}); }));
}; };
this.sumSeries = function(timeseries) { this.sumSeries = function(timeseries) {
@@ -190,11 +190,6 @@ function (angular, _, moment, utils) {
return nearestLeft; return nearestLeft;
} }
this.medianBy = function(interval, timeseries) {
var flatten_series = _.flatten(timeseries, true);
return self.groupBy(interval, self.MEDIAN, flatten_series);
};
this.AVERAGE = function(values) { this.AVERAGE = function(values) {
var sum = 0; var sum = 0;
_.each(values, function(value) { _.each(values, function(value) {
@@ -243,8 +238,8 @@ function (angular, _, moment, utils) {
average: _.partial(this.aggregateWrapper, this.AVERAGE), average: _.partial(this.aggregateWrapper, this.AVERAGE),
min: _.partial(this.aggregateWrapper, this.MIN), min: _.partial(this.aggregateWrapper, this.MIN),
max: _.partial(this.aggregateWrapper, this.MAX), max: _.partial(this.aggregateWrapper, this.MAX),
median: _.partial(this.aggregateWrapper, this.MEDIAN),
sumSeries: this.sumSeries, sumSeries: this.sumSeries,
medianBy: this.medianBy,
setAlias: this.setAlias, setAlias: this.setAlias,
}; };

View File

@@ -41,7 +41,7 @@ function (_, $) {
}); });
addFuncDef({ addFuncDef({
name: 'medianBy', name: 'median',
category: 'Aggregate', category: 'Aggregate',
params: [ params: [
{ name: 'interval', type: 'string'} { name: 'interval', type: 'string'}