pass timerange in meta data queries

This commit is contained in:
Sven Klemm 2018-08-31 18:24:09 +02:00
parent cd708d6cb2
commit bcfb841cb4
2 changed files with 16 additions and 2 deletions

View File

@ -9,7 +9,7 @@ export class MysqlDatasource {
queryModel: MysqlQuery;
/** @ngInject **/
constructor(instanceSettings, private backendSrv, private $q, private templateSrv) {
constructor(instanceSettings, private backendSrv, private $q, private templateSrv, private timeSrv) {
this.name = instanceSettings.name;
this.id = instanceSettings.id;
this.responseParser = new ResponseParser(this.$q);
@ -108,8 +108,11 @@ export class MysqlDatasource {
format: 'table',
};
const range = this.timeSrv.timeRange();
const data = {
queries: [interpolatedQuery],
from: range.from.valueOf().toString(),
to: range.to.valueOf().toString(),
};
if (optionalOptions && optionalOptions.range && optionalOptions.range.from) {

View File

@ -9,12 +9,23 @@ describe('MySQLDatasource', function() {
replace: jest.fn(text => text),
};
const raw = {
from: moment.utc('2018-04-25 10:00'),
to: moment.utc('2018-04-25 11:00'),
};
const ctx = <any>{
backendSrv,
timeSrvMock: {
timeRange: () => ({
from: raw.from,
to: raw.to,
raw: raw,
}),
},
};
beforeEach(() => {
ctx.ds = new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv);
ctx.ds = new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv, ctx.timeSrvMock);
});
describe('When performing annotationQuery', function() {