Бунин Олег Александрович
2018-04-19 17:40:08 +03:00
parent f0a5e7de8d
commit e78387fcb0
72 changed files with 4110 additions and 4005 deletions

View File

@@ -36,6 +36,33 @@ function limit(order, n, orderByFunc, timeseries) {
}
}
function removeAboveValue(n, datapoints) {
return _.map(datapoints, point => {
return [
(point[0] > n) ? null : point[0],
point[1]
];
});
}
function removeBelowValue(n, datapoints) {
return _.map(datapoints, point => {
return [
(point[0] < n) ? null : point[0],
point[1]
];
});
}
function transformNull(n, datapoints) {
return _.map(datapoints, point => {
return [
(point[0] !== null) ? point[0] : n,
point[1]
];
});
}
function sortSeries(direction, timeseries) {
return _.orderBy(timeseries, [function (ts) {
return ts.target.toLowerCase();
@@ -121,6 +148,7 @@ let metricFunctions = {
rate: rate,
movingAverage: simpleMovingAverage,
exponentialMovingAverage: expMovingAverage,
transformNull: transformNull,
aggregateBy: aggregateByWrapper,
// Predefined aggs
percentil: percentil,
@@ -131,6 +159,8 @@ let metricFunctions = {
sum: _.partial(aggregateWrapper, SUM),
count: _.partial(aggregateWrapper, COUNT),
sumSeries: sumSeries,
removeAboveValue: removeAboveValue,
removeBelowValue: removeBelowValue,
top: _.partial(limit, 'top'),
bottom: _.partial(limit, 'bottom'),
sortSeries: sortSeries,

View File

@@ -76,6 +76,15 @@ addFuncDef({
defaultParams: [0.2],
});
addFuncDef({
name: 'transformNull',
category: 'Transform',
params: [
{name: 'number', type: 'float'}
],
defaultParams: [0],
});
// Aggregate
addFuncDef({
@@ -161,6 +170,24 @@ addFuncDef({
// Filter
addFuncDef({
name: 'removeAboveValue',
category: 'Filter',
params: [
{name: 'number', type: 'float'},
],
defaultParams: [0],
});
addFuncDef({
name: 'removeBelowValue',
category: 'Filter',
params: [
{name: 'number', type: 'float'},
],
defaultParams: [0],
});
addFuncDef({
name: 'top',
category: 'Filter',