mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
pass timerange in meta data queries
This commit is contained in:
parent
cd708d6cb2
commit
bcfb841cb4
@ -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) {
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user