|
@@ -964,26 +964,23 @@ export class FuncInstance {
|
|
|
render(metricExp) {
|
|
render(metricExp) {
|
|
|
const str = this.def.name + '(';
|
|
const str = this.def.name + '(';
|
|
|
|
|
|
|
|
- const parameters = _.map(
|
|
|
|
|
- this.params,
|
|
|
|
|
- function(value, index) {
|
|
|
|
|
- let paramType;
|
|
|
|
|
- if (index < this.def.params.length) {
|
|
|
|
|
- paramType = this.def.params[index].type;
|
|
|
|
|
- } else if (_.get(_.last(this.def.params), 'multiple')) {
|
|
|
|
|
- paramType = _.get(_.last(this.def.params), 'type');
|
|
|
|
|
- }
|
|
|
|
|
- // param types that should never be quoted
|
|
|
|
|
- if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) {
|
|
|
|
|
- return value;
|
|
|
|
|
- }
|
|
|
|
|
- // param types that might be quoted
|
|
|
|
|
- if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+value)) {
|
|
|
|
|
- return _.toString(+value);
|
|
|
|
|
- }
|
|
|
|
|
- return "'" + value + "'";
|
|
|
|
|
- }.bind(this)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ const parameters = _.map(this.params, (value, index) => {
|
|
|
|
|
+ let paramType;
|
|
|
|
|
+ if (index < this.def.params.length) {
|
|
|
|
|
+ paramType = this.def.params[index].type;
|
|
|
|
|
+ } else if (_.get(_.last(this.def.params), 'multiple')) {
|
|
|
|
|
+ paramType = _.get(_.last(this.def.params), 'type');
|
|
|
|
|
+ }
|
|
|
|
|
+ // param types that should never be quoted
|
|
|
|
|
+ if (_.includes(['value_or_series', 'boolean', 'int', 'float', 'node'], paramType)) {
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ // param types that might be quoted
|
|
|
|
|
+ if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+value)) {
|
|
|
|
|
+ return _.toString(+value);
|
|
|
|
|
+ }
|
|
|
|
|
+ return "'" + value + "'";
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
// don't send any blank parameters to graphite
|
|
// don't send any blank parameters to graphite
|
|
|
while (parameters[parameters.length - 1] === '') {
|
|
while (parameters[parameters.length - 1] === '') {
|
|
@@ -1017,12 +1014,9 @@ export class FuncInstance {
|
|
|
// 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) {
|
|
|
|
|
- this.updateParam(partVal.trim(), index + idx);
|
|
|
|
|
- }.bind(this)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ _.each(strValue.split(','), (partVal, idx) => {
|
|
|
|
|
+ this.updateParam(partVal.trim(), index + idx);
|
|
|
|
|
+ });
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|