Skip to content

Commit

Permalink
Graphite: movingAverage / movingMedian parameter type impovement, now…
Browse files Browse the repository at this point in the history
… handles int and interval parameter, Fixes #1207
  • Loading branch information
torkelo committed Dec 15, 2014
1 parent 3c1b30e commit acd944a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**Fixes**
- [Issue #1199](https://github.com/grafana/grafana/issues/1199). Graph: fix for series tooltip when one series is hidden/disabled
- [Issue #1207](https://github.com/grafana/grafana/issues/1207). Graphite: movingAverage / movingMedian parameter type impovement, now handles int and interval parameter

# 1.9.0 (2014-12-02)

Expand Down
14 changes: 9 additions & 5 deletions src/app/services/graphite/gfunc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
define([
'lodash'
'lodash',
'jquery'
],
function (_) {
function (_, $) {
'use strict';

var index = [];
Expand Down Expand Up @@ -501,15 +502,15 @@ function (_) {
addFuncDef({
name: 'movingAverage',
category: categories.Filter,
params: [{ name: "window size", type: "int" }],
params: [{ name: "windowSize", type: "int_or_interval", options: ['5', '7', '10', '5min', '10min', '30min', '1hour'] }],
defaultParams: [10]
});

addFuncDef({
name: 'movingMedian',
category: categories.Filter,
params: [{ name: "windowSize", type: "select", options: ['1min', '5min', '15min', '30min', '1hour'] }],
defaultParams: ['1min']
params: [{ name: "windowSize", type: "int_or_interval", options: ['5', '7', '10', '5min', '10min', '30min', '1hour'] }],
defaultParams: ['5']
});

addFuncDef({
Expand Down Expand Up @@ -595,6 +596,9 @@ function (_) {
if (paramType === 'int' || paramType === 'value_or_series' || paramType === 'boolean') {
return value;
}
else if (paramType === 'int_or_interval' && $.isNumeric(value)) {
return value;
}

return "'" + value + "'";

Expand Down
12 changes: 12 additions & 0 deletions src/test/specs/gfunc-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ define([
expect(func.render('hello')).to.equal("scaleToSeconds(hello, 1)");
});

it('should handle int or interval params with number', function() {
var func = gfunc.createFuncInstance('movingMedian');
func.params[0] = '5';
expect(func.render('hello')).to.equal("movingMedian(hello, 5)");
});

it('should handle int or interval params with interval string', function() {
var func = gfunc.createFuncInstance('movingMedian');
func.params[0] = '5min';
expect(func.render('hello')).to.equal("movingMedian(hello, '5min')");
});

it('should handle metric param and int param and string param', function() {
var func = gfunc.createFuncInstance('groupByNode');
func.params[0] = 5;
Expand Down

0 comments on commit acd944a

Please sign in to comment.