Replaced old downsampleSeries() method by new
DataProcessingService.groupBy()
This commit is contained in:
@@ -2,6 +2,7 @@ define([
|
||||
'angular',
|
||||
'lodash',
|
||||
'app/core/utils/datemath',
|
||||
'./utils',
|
||||
'./queryProcessor',
|
||||
'./directives',
|
||||
'./zabbixAPI',
|
||||
@@ -10,7 +11,7 @@ define([
|
||||
'./zabbixCache',
|
||||
'./queryCtrl'
|
||||
],
|
||||
function (angular, _, dateMath) {
|
||||
function (angular, _, dateMath, utils) {
|
||||
'use strict';
|
||||
|
||||
/** @ngInject */
|
||||
@@ -141,15 +142,15 @@ function (angular, _, dateMath) {
|
||||
|
||||
return getHistory.then(function (timeseries_data) {
|
||||
return _.map(timeseries_data, function (timeseries) {
|
||||
var groupBuInterval = utils.parseInterval(options.interval);
|
||||
|
||||
// Series downsampling
|
||||
if (timeseries.datapoints.length > options.maxDataPoints) {
|
||||
var ms_interval = Math.floor((to - from) / options.maxDataPoints) * 1000;
|
||||
var downsampleFunc = target.downsampleFunction ? target.downsampleFunction.value : "avg";
|
||||
timeseries.datapoints = zabbixHelperSrv.downsampleSeries(timeseries.datapoints, to, ms_interval, downsampleFunc);
|
||||
timeseries.datapoints = DataProcessingService.groupBy(timeseries.datapoints,
|
||||
groupBuInterval,
|
||||
DataProcessingService.AVERAGE);
|
||||
}
|
||||
var groupBuInterval = 60000;
|
||||
timeseries.datapoints = DataProcessingService.groupBy(timeseries.datapoints, groupBuInterval, DataProcessingService.AVERAGE);
|
||||
|
||||
return timeseries;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
define([
|
||||
'lodash'
|
||||
'lodash',
|
||||
'moment'
|
||||
],
|
||||
function () {
|
||||
function (_, moment) {
|
||||
'use strict';
|
||||
|
||||
function utils() {
|
||||
@@ -40,6 +41,12 @@ function () {
|
||||
return new RegExp(pattern, flags);
|
||||
};
|
||||
|
||||
this.parseInterval = function(interval) {
|
||||
var intervalPattern = /(^[\d]+)(y|M|w|d|h|m|s)/g;
|
||||
var momentInterval = intervalPattern.exec(interval);
|
||||
return moment.duration(Number(momentInterval[1]), momentInterval[2]).valueOf();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return new utils();
|
||||
|
||||
Reference in New Issue
Block a user