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