Commit 8526230b by Torkel Ödegaard

fix(influxdb_08): fixed influxdb 08 query editor issue, fixes #3009

parent 9d04a4c4
...@@ -2,11 +2,11 @@ define([ ...@@ -2,11 +2,11 @@ define([
'angular', 'angular',
'lodash', 'lodash',
'app/core/utils/datemath', 'app/core/utils/datemath',
'./influxSeries', './influx_series',
'./queryBuilder', './query_builder',
'./directives', './directives',
'./queryCtrl', './query_ctrl',
'./funcEditor', './func_editor',
], ],
function (angular, _, dateMath, InfluxSeries, InfluxQueryBuilder) { function (angular, _, dateMath, InfluxSeries, InfluxQueryBuilder) {
'use strict'; 'use strict';
......
...@@ -89,6 +89,7 @@ function (angular) { ...@@ -89,6 +89,7 @@ function (angular) {
} }
}; };
}); $scope.init();
});
}); });
define([ ///<amd-dependency path="app/plugins/datasource/influxdb_08/datasource"/>
'./helpers', ///<amd-dependency path="app/services/backendSrv"/>
'app/plugins/datasource/influxdb_08/datasource', ///<amd-dependency path="app/services/alertSrv"/>
'app/services/backendSrv', ///<amd-dependency path="test/specs/helpers" name="helpers" />
'app/services/alertSrv'
], function(helpers) { import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
'use strict';
declare var helpers: any;
describe('InfluxDatasource', function() {
describe('InfluxDatasource', function() {
var ctx = new helpers.ServiceTestContext(); var ctx = new helpers.ServiceTestContext();
beforeEach(module('grafana.services')); beforeEach(angularMocks.module('grafana.services'));
beforeEach(ctx.providePhase(['templateSrv'])); beforeEach(ctx.providePhase(['templateSrv']));
beforeEach(ctx.createService('InfluxDatasource_08')); beforeEach(ctx.createService('InfluxDatasource_08'));
beforeEach(function() { beforeEach(function() {
...@@ -18,8 +19,7 @@ define([ ...@@ -18,8 +19,7 @@ define([
describe('When querying influxdb with one target using query editor target spec', function() { describe('When querying influxdb with one target using query editor target spec', function() {
var results; var results;
var urlExpected = "/series?p=mupp&q=select+mean(value)+from+%22test%22"+ var urlExpected = "/series?p=mupp&q=select+mean(value)+from+%22test%22+where+time+%3E+now()-1h+group+by+time(1s)+order+asc";
"+where+time+%3E+now()-1h+group+by+time(1s)+order+asc";
var query = { var query = {
rangeRaw: { from: 'now-1h', to: 'now' }, rangeRaw: { from: 'now-1h', to: 'now' },
targets: [{ series: 'test', column: 'value', function: 'mean' }], targets: [{ series: 'test', column: 'value', function: 'mean' }],
...@@ -51,8 +51,7 @@ define([ ...@@ -51,8 +51,7 @@ define([
describe('When querying influxdb with one raw query', function() { describe('When querying influxdb with one raw query', function() {
var results; var results;
var urlExpected = "/series?p=mupp&q=select+value+from+series"+ var urlExpected = "/series?p=mupp&q=select+value+from+series+where+time+%3E+now()-1h";
"+where+time+%3E+now()-1h";
var query = { var query = {
rangeRaw: { from: 'now-1h', to: 'now' }, rangeRaw: { from: 'now-1h', to: 'now' },
targets: [{ query: "select value from series where $timeFilter", rawQuery: true }] targets: [{ query: "select value from series where $timeFilter", rawQuery: true }]
...@@ -74,8 +73,7 @@ define([ ...@@ -74,8 +73,7 @@ define([
describe('When issuing annotation query', function() { describe('When issuing annotation query', function() {
var results; var results;
var urlExpected = "/series?p=mupp&q=select+title+from+events.backend_01"+ var urlExpected = "/series?p=mupp&q=select+title+from+events.backend_01+where+time+%3E+now()-1h";
"+where+time+%3E+now()-1h";
var range = { from: 'now-1h', to: 'now' }; var range = { from: 'now-1h', to: 'now' };
var annotation = { query: 'select title from events.$server where $timeFilter' }; var annotation = { query: 'select title from events.$server where $timeFilter' };
...@@ -96,6 +94,4 @@ define([ ...@@ -96,6 +94,4 @@ define([
}); });
});
}); });
define([ ///<amd-dependency path="app/plugins/datasource/influxdb_08/influx_series" name="InfluxSeries"/>
'app/plugins/datasource/influxdb_08/influxSeries'
], function(InfluxSeries) {
'use strict';
describe('when generating timeseries from influxdb response', function() { import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var InfluxSeries: any;
describe('when generating timeseries from influxdb response', function() {
describe('given two series', function() { describe('given two series', function() {
var series = new InfluxSeries({ var series = new InfluxSeries({
...@@ -158,9 +159,9 @@ define([ ...@@ -158,9 +159,9 @@ define([
}); });
}); });
describe("when creating annotations from influxdb response", function() { describe("when creating annotations from influxdb response", function() {
describe('given column mapping for all columns', function() { describe('given column mapping for all columns', function() {
var series = new InfluxSeries({ var series = new InfluxSeries({
seriesList: [ seriesList: [
...@@ -215,6 +216,5 @@ define([ ...@@ -215,6 +216,5 @@ define([
}); });
});
}); });
define([ ///<amd-dependency path="app/plugins/datasource/influxdb_08/query_builder" name="InfluxQueryBuilder"/>
'app/plugins/datasource/influxdb_08/queryBuilder'
], function(InfluxQueryBuilder) {
'use strict';
describe('InfluxQueryBuilder', function() { import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var InfluxQueryBuilder: any;
describe('InfluxQueryBuilder', function() {
describe('series with conditon and group by', function() { describe('series with conditon and group by', function() {
var builder = new InfluxQueryBuilder({ var builder = new InfluxQueryBuilder({
...@@ -73,6 +74,5 @@ define([ ...@@ -73,6 +74,5 @@ define([
}); });
});
}); });
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