Commit 9bdcc4ec by Torkel Ödegaard

influxdb: holt winters edits

parents 0384eecf cdfb24ab
...@@ -32,6 +32,15 @@ func init() { ...@@ -32,6 +32,15 @@ func init() {
renders["median"] = QueryDefinition{Renderer: functionRenderer} renders["median"] = QueryDefinition{Renderer: functionRenderer}
renders["sum"] = QueryDefinition{Renderer: functionRenderer} renders["sum"] = QueryDefinition{Renderer: functionRenderer}
renders["holt_winters"] = QueryDefinition{
Renderer: functionRenderer,
Params: []DefinitionParameters{{Name: "number", Type: "number"}, {Name: "season", Type: "number"}},
}
renders["holt_winters_with_fit"] = QueryDefinition{
Renderer: functionRenderer,
Params: []DefinitionParameters{{Name: "number", Type: "number"}, {Name: "season", Type: "number"}},
}
renders["derivative"] = QueryDefinition{ renders["derivative"] = QueryDefinition{
Renderer: functionRenderer, Renderer: functionRenderer,
Params: []DefinitionParameters{{Name: "duration", Type: "interval"}}, Params: []DefinitionParameters{{Name: "duration", Type: "interval"}},
...@@ -49,7 +58,7 @@ func init() { ...@@ -49,7 +58,7 @@ func init() {
renders["stddev"] = QueryDefinition{Renderer: functionRenderer} renders["stddev"] = QueryDefinition{Renderer: functionRenderer}
renders["time"] = QueryDefinition{ renders["time"] = QueryDefinition{
Renderer: functionRenderer, Renderer: functionRenderer,
Params: []DefinitionParameters{{Name: "interval", Type: "time"}}, Params: []DefinitionParameters{{Name: "interval", Type: "time"}, {Name: "offset", Type: "time"}},
} }
renders["fill"] = QueryDefinition{ renders["fill"] = QueryDefinition{
Renderer: functionRenderer, Renderer: functionRenderer,
......
...@@ -91,7 +91,13 @@ export function queryPartEditorDirective($compile, templateSrv) { ...@@ -91,7 +91,13 @@ export function queryPartEditorDirective($compile, templateSrv) {
} }
var typeaheadSource = function (query, callback) { var typeaheadSource = function (query, callback) {
if (param.options) { return param.options; } if (param.options) {
var options = param.options;
if (param.type === 'int') {
options = _.map(options, function(val) { return val.toString(); });
}
return options;
}
$scope.$apply(function() { $scope.$apply(function() {
$scope.handleEvent({$event: {name: 'get-param-options'}}).then(function(result) { $scope.handleEvent({$event: {name: 'get-param-options'}}).then(function(result) {
...@@ -102,10 +108,6 @@ export function queryPartEditorDirective($compile, templateSrv) { ...@@ -102,10 +108,6 @@ export function queryPartEditorDirective($compile, templateSrv) {
}; };
$input.attr('data-provide', 'typeahead'); $input.attr('data-provide', 'typeahead');
var options = param.options;
if (param.type === 'int') {
options = _.map(options, function(val) { return val.toString(); });
}
$input.typeahead({ $input.typeahead({
source: typeaheadSource, source: typeaheadSource,
......
...@@ -15,6 +15,7 @@ var categories = { ...@@ -15,6 +15,7 @@ var categories = {
Aggregations: [], Aggregations: [],
Selectors: [], Selectors: [],
Transformations: [], Transformations: [],
Predictors: [],
Math: [], Math: [],
Aliasing: [], Aliasing: [],
Fields: [], Fields: [],
...@@ -233,7 +234,7 @@ register({ ...@@ -233,7 +234,7 @@ register({
type: 'moving_average', type: 'moving_average',
addStrategy: addTransformationStrategy, addStrategy: addTransformationStrategy,
category: categories.Transformations, category: categories.Transformations,
params: [{ name: "window", type: "number", options: [5, 10, 20, 30, 40]}], params: [{ name: "window", type: "int", options: [5, 10, 20, 30, 40]}],
defaultParams: [10], defaultParams: [10],
renderer: functionRenderer, renderer: functionRenderer,
}); });
...@@ -259,8 +260,8 @@ register({ ...@@ -259,8 +260,8 @@ register({
register({ register({
type: 'time', type: 'time',
category: groupByTimeFunctions, category: groupByTimeFunctions,
params: [{ name: "interval", type: "time", options: ['auto', '1s', '10s', '1m', '5m', '10m', '15m', '1h'] }], params: [{ name: "interval", type: "time", options: ['$__interval', '1s', '10s', '1m', '5m', '10m', '15m', '1h']}],
defaultParams: ['auto'], defaultParams: ['$__interval'],
renderer: functionRenderer, renderer: functionRenderer,
}); });
...@@ -281,6 +282,26 @@ register({ ...@@ -281,6 +282,26 @@ register({
renderer: functionRenderer, renderer: functionRenderer,
}); });
// predictions
register({
type: 'holt_winters',
addStrategy: addTransformationStrategy,
category: categories.Predictors,
params: [{ name: "number", type: "int", options: [5, 10, 20, 30, 40]}, { name: "season", type: "int", options: [0, 1, 2, 5, 10]}],
defaultParams: [10, 2],
renderer: functionRenderer,
});
debugger;
register({
type: 'holt_winters_with_fit',
addStrategy: addTransformationStrategy,
category: categories.Predictors,
params: [{ name: "number", type: "int", options: [5, 10, 20, 30, 40]}, { name: "season", type: "int", options: [0, 1, 2, 5, 10]}],
defaultParams: [10, 2],
renderer: functionRenderer,
});
// Selectors // Selectors
register({ register({
type: 'bottom', type: 'bottom',
......
...@@ -123,8 +123,7 @@ describe('InfluxQuery', function() { ...@@ -123,8 +123,7 @@ describe('InfluxQuery', function() {
}, templateSrv, {}); }, templateSrv, {});
var queryText = query.render(); var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter ' + expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter GROUP BY time($__interval), "host"');
'GROUP BY time($__interval), "host"');
}); });
}); });
......
...@@ -2,6 +2,7 @@ module.exports = function(config) { ...@@ -2,6 +2,7 @@ module.exports = function(config) {
'use strict' 'use strict'
return { return {
tslint : "node ./node_modules/tslint/lib/tslint-cli.js -c tslint.json --project ./tsconfig.json", tslint : "node ./node_modules/tslint/lib/tslint-cli.js -c tslint.json --project ./tsconfig.json",
tscompile: "node ./node_modules/typescript/lib/tsc.js -p tsconfig.json --diagnostics" tscompile: "node ./node_modules/typescript/lib/tsc.js -p tsconfig.json --diagnostics",
tswatch: "node ./node_modules/typescript/lib/tsc.js -p tsconfig.json --diagnostics --watch",
}; };
}; };
...@@ -54,19 +54,19 @@ module.exports = function(config, grunt) { ...@@ -54,19 +54,19 @@ module.exports = function(config, grunt) {
grunt.task.run('css'); grunt.task.run('css');
} }
if (/(\.ts)$/.test(filepath)) { // if (/(\.ts)$/.test(filepath)) {
newPath = filepath.replace(/^public/, 'public_gen'); // newPath = filepath.replace(/^public/, 'public_gen');
grunt.log.writeln('Copying to ' + newPath); // grunt.log.writeln('Copying to ' + newPath);
grunt.file.copy(filepath, newPath); // grunt.file.copy(filepath, newPath);
//
// copy ts file also used by source maps // // copy ts file also used by source maps
//changes changed file source to that of the changed file // //changes changed file source to that of the changed file
grunt.config('typescript.build.src', filepath); // grunt.config('typescript.build.src', filepath);
grunt.config('tslint.source.files.src', filepath); // grunt.config('tslint.source.files.src', filepath);
//
grunt.task.run('exec:tscompile'); // grunt.task.run('exec:tscompile');
grunt.task.run('exec:tslint'); // grunt.task.run('exec:tslint');
} // }
done(); done();
firstRun = false; firstRun = false;
......
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