Commit 30bf8380 by Torkel Ödegaard

added smartSummarize graphite function definition

parent 0019101f
...@@ -140,7 +140,7 @@ function (_) { ...@@ -140,7 +140,7 @@ function (_) {
], ],
defaultParams: ['max'] defaultParams: ['max']
}); });
addFuncDef({ addFuncDef({
name: "groupByNode", name: "groupByNode",
category: categories.Special, category: categories.Special,
...@@ -286,6 +286,13 @@ function (_) { ...@@ -286,6 +286,13 @@ function (_) {
}); });
addFuncDef({ addFuncDef({
name: 'smartSummarize',
category: categories.Transform,
params: [ { name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }],
defaultParams: ['1h', 'sum']
});
addFuncDef({
name: 'absolute', name: 'absolute',
category: categories.Transform, category: categories.Transform,
}); });
...@@ -490,25 +497,25 @@ function (_) { ...@@ -490,25 +497,25 @@ function (_) {
return this.def.params[index + 1] && this.def.params[index + 1].optional; return this.def.params[index + 1] && this.def.params[index + 1].optional;
}; };
FuncInstance.prototype.updateParam = function(strValue, index) { FuncInstance.prototype.updateParam = function(strValue, index) {
// handle optional parameters // handle optional parameters
// if string contains ',' and next param is optional, split and update both // if string contains ',' and next param is optional, split and update both
if (this._hasMultipleParamsInString(strValue, index)) { if (this._hasMultipleParamsInString(strValue, index)) {
_.each(strValue.split(','), function(partVal, idx) { _.each(strValue.split(','), function(partVal, idx) {
this.updateParam(partVal.trim(), idx); this.updateParam(partVal.trim(), idx);
}, this); }, this);
return; return;
} }
if (strValue === '' && this.def.params[index].optional) { if (strValue === '' && this.def.params[index].optional) {
this.params.splice(index, 1); this.params.splice(index, 1);
} }
else if (this.def.params[index].type === 'int') { else if (this.def.params[index].type === 'int') {
this.params[index] = parseFloat(strValue, 10); this.params[index] = parseFloat(strValue, 10);
} }
else { else {
this.params[index] = strValue; this.params[index] = strValue;
} }
this.updateText(); this.updateText();
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment