mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
noImplicitAny: Sub 3000 errors (#17821)
* noImplicitAny Stackdriver * Sub 3000 noImplicitAny * Update error count limit * Add DataQueryRequest type
This commit is contained in:
committed by
Torkel Ödegaard
parent
bd4a7ddf3a
commit
4e27ba9646
@@ -1,6 +1,10 @@
|
||||
import _ from 'lodash';
|
||||
import ResponseParser from './response_parser';
|
||||
import MysqlQuery from 'app/plugins/datasource/mysql/mysql_query';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
import { IQService } from 'angular';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
|
||||
export class MysqlDatasource {
|
||||
id: any;
|
||||
@@ -10,7 +14,13 @@ export class MysqlDatasource {
|
||||
interval: string;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(instanceSettings, private backendSrv, private $q, private templateSrv, private timeSrv) {
|
||||
constructor(
|
||||
instanceSettings: any,
|
||||
private backendSrv: BackendSrv,
|
||||
private $q: IQService,
|
||||
private templateSrv: TemplateSrv,
|
||||
private timeSrv: TimeSrv
|
||||
) {
|
||||
this.name = instanceSettings.name;
|
||||
this.id = instanceSettings.id;
|
||||
this.responseParser = new ResponseParser(this.$q);
|
||||
@@ -18,7 +28,7 @@ export class MysqlDatasource {
|
||||
this.interval = (instanceSettings.jsonData || {}).timeInterval || '1m';
|
||||
}
|
||||
|
||||
interpolateVariable = (value, variable) => {
|
||||
interpolateVariable = (value: string, variable: any) => {
|
||||
if (typeof value === 'string') {
|
||||
if (variable.multi || variable.includeAll) {
|
||||
return this.queryModel.quoteLiteral(value);
|
||||
@@ -31,13 +41,13 @@ export class MysqlDatasource {
|
||||
return value;
|
||||
}
|
||||
|
||||
const quotedValues = _.map(value, v => {
|
||||
const quotedValues = _.map(value, (v: any) => {
|
||||
return this.queryModel.quoteLiteral(v);
|
||||
});
|
||||
return quotedValues.join(',');
|
||||
};
|
||||
|
||||
query(options) {
|
||||
query(options: any) {
|
||||
const queries = _.filter(options.targets, target => {
|
||||
return target.hide !== true;
|
||||
}).map(target => {
|
||||
@@ -48,7 +58,7 @@ export class MysqlDatasource {
|
||||
intervalMs: options.intervalMs,
|
||||
maxDataPoints: options.maxDataPoints,
|
||||
datasourceId: this.id,
|
||||
rawSql: queryModel.render(this.interpolateVariable),
|
||||
rawSql: queryModel.render(this.interpolateVariable as any),
|
||||
format: target.format,
|
||||
};
|
||||
});
|
||||
@@ -70,7 +80,7 @@ export class MysqlDatasource {
|
||||
.then(this.responseParser.processQueryResult);
|
||||
}
|
||||
|
||||
annotationQuery(options) {
|
||||
annotationQuery(options: any) {
|
||||
if (!options.annotation.rawQuery) {
|
||||
return this.$q.reject({
|
||||
message: 'Query missing in annotation definition',
|
||||
@@ -94,10 +104,10 @@ export class MysqlDatasource {
|
||||
queries: [query],
|
||||
},
|
||||
})
|
||||
.then(data => this.responseParser.transformAnnotationResponse(options, data));
|
||||
.then((data: any) => this.responseParser.transformAnnotationResponse(options, data));
|
||||
}
|
||||
|
||||
metricFindQuery(query, optionalOptions) {
|
||||
metricFindQuery(query: string, optionalOptions: any) {
|
||||
let refId = 'tempvar';
|
||||
if (optionalOptions && optionalOptions.variable && optionalOptions.variable.name) {
|
||||
refId = optionalOptions.variable.name;
|
||||
@@ -130,7 +140,7 @@ export class MysqlDatasource {
|
||||
method: 'POST',
|
||||
data: data,
|
||||
})
|
||||
.then(data => this.responseParser.parseMetricFindQueryResult(refId, data));
|
||||
.then((data: any) => this.responseParser.parseMetricFindQueryResult(refId, data));
|
||||
}
|
||||
|
||||
testDatasource() {
|
||||
@@ -153,10 +163,10 @@ export class MysqlDatasource {
|
||||
],
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
.then((res: any) => {
|
||||
return { status: 'success', message: 'Database Connection OK' };
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err: any) => {
|
||||
console.log(err);
|
||||
if (err.data && err.data.message) {
|
||||
return { status: 'error', message: err.data.message };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class MysqlMetaQuery {
|
||||
constructor(private target, private queryModel) {}
|
||||
constructor(private target: any, private queryModel: any) {}
|
||||
|
||||
getOperators(datatype: string) {
|
||||
switch (datatype) {
|
||||
@@ -22,7 +22,7 @@ export class MysqlMetaQuery {
|
||||
}
|
||||
|
||||
// quote identifier as literal to use in metadata queries
|
||||
quoteIdentAsLiteral(value) {
|
||||
quoteIdentAsLiteral(value: string) {
|
||||
return this.queryModel.quoteLiteral(this.queryModel.unquoteIdentifier(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { ScopedVars } from '@grafana/ui';
|
||||
|
||||
export default class MysqlQuery {
|
||||
target: any;
|
||||
@@ -6,7 +8,7 @@ export default class MysqlQuery {
|
||||
scopedVars: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(target, templateSrv?, scopedVars?) {
|
||||
constructor(target: any, templateSrv?: TemplateSrv, scopedVars?: ScopedVars) {
|
||||
this.target = target;
|
||||
this.templateSrv = templateSrv;
|
||||
this.scopedVars = scopedVars;
|
||||
@@ -35,7 +37,7 @@ export default class MysqlQuery {
|
||||
}
|
||||
|
||||
// remove identifier quoting from identifier to use in metadata queries
|
||||
unquoteIdentifier(value) {
|
||||
unquoteIdentifier(value: string) {
|
||||
if (value[0] === '"' && value[value.length - 1] === '"') {
|
||||
return value.substring(1, value.length - 1).replace(/""/g, '"');
|
||||
} else {
|
||||
@@ -43,15 +45,15 @@ export default class MysqlQuery {
|
||||
}
|
||||
}
|
||||
|
||||
quoteIdentifier(value) {
|
||||
quoteIdentifier(value: string) {
|
||||
return '"' + value.replace(/"/g, '""') + '"';
|
||||
}
|
||||
|
||||
quoteLiteral(value) {
|
||||
quoteLiteral(value: string) {
|
||||
return "'" + value.replace(/'/g, "''") + "'";
|
||||
}
|
||||
|
||||
escapeLiteral(value) {
|
||||
escapeLiteral(value: any) {
|
||||
return String(value).replace(/'/g, "''");
|
||||
}
|
||||
|
||||
@@ -63,7 +65,7 @@ export default class MysqlQuery {
|
||||
return this.target.metricColumn !== 'none';
|
||||
}
|
||||
|
||||
interpolateQueryStr(value, variable, defaultFormatFn) {
|
||||
interpolateQueryStr(value: string, variable: { multi: any; includeAll: any }, defaultFormatFn: any) {
|
||||
// if no multi or include all do not regexEscape
|
||||
if (!variable.multi && !variable.includeAll) {
|
||||
return this.escapeLiteral(value);
|
||||
@@ -77,7 +79,7 @@ export default class MysqlQuery {
|
||||
return escapedValues.join(',');
|
||||
}
|
||||
|
||||
render(interpolate?) {
|
||||
render(interpolate?: boolean) {
|
||||
const target = this.target;
|
||||
|
||||
// new query with no table set yet
|
||||
@@ -146,7 +148,7 @@ export default class MysqlQuery {
|
||||
return query;
|
||||
}
|
||||
|
||||
buildValueColumn(column) {
|
||||
buildValueColumn(column: any) {
|
||||
let query = '';
|
||||
|
||||
const columnName: any = _.find(column, (g: any) => g.type === 'column');
|
||||
|
||||
@@ -5,6 +5,8 @@ import { QueryCtrl } from 'app/plugins/sdk';
|
||||
import { SqlPart } from 'app/core/components/sql_part/sql_part';
|
||||
import MysqlQuery from './mysql_query';
|
||||
import sqlPart from './sql_part';
|
||||
import { auto, IQService } from 'angular';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
|
||||
export interface QueryMeta {
|
||||
sql: string;
|
||||
@@ -41,7 +43,13 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
groupAdd: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, $injector, private templateSrv, private $q, private uiSegmentSrv) {
|
||||
constructor(
|
||||
$scope: any,
|
||||
$injector: auto.IInjectorService,
|
||||
private templateSrv: TemplateSrv,
|
||||
private $q: IQService,
|
||||
private uiSegmentSrv: any
|
||||
) {
|
||||
super($scope, $injector);
|
||||
|
||||
this.target = this.target;
|
||||
@@ -59,7 +67,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.target.rawQuery = true;
|
||||
} else {
|
||||
this.target.rawSql = defaultQuery;
|
||||
this.datasource.metricFindQuery(this.metaBuilder.findMetricTable()).then(result => {
|
||||
this.datasource.metricFindQuery(this.metaBuilder.findMetricTable()).then((result: any) => {
|
||||
if (result.length > 0) {
|
||||
this.target.table = result[0].text;
|
||||
let segment = this.uiSegmentSrv.newSegment(this.target.table);
|
||||
@@ -156,7 +164,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
resetPlusButton(button) {
|
||||
resetPlusButton(button: { html: any; value: any }) {
|
||||
const plusButton = this.uiSegmentSrv.newPlusButton();
|
||||
button.html = plusButton.html;
|
||||
button.value = plusButton.value;
|
||||
@@ -180,7 +188,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.metricColumnSegment.value = segment.value;
|
||||
this.target.metricColumn = 'none';
|
||||
|
||||
const task1 = this.datasource.metricFindQuery(this.metaBuilder.buildColumnQuery('time')).then(result => {
|
||||
const task1 = this.datasource.metricFindQuery(this.metaBuilder.buildColumnQuery('time')).then((result: any) => {
|
||||
// check if time column is still valid
|
||||
if (result.length > 0 && !_.find(result, (r: any) => r.text === this.target.timeColumn)) {
|
||||
const segment = this.uiSegmentSrv.newSegment(result[0].text);
|
||||
@@ -189,7 +197,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
return this.timeColumnChanged(false);
|
||||
});
|
||||
const task2 = this.datasource.metricFindQuery(this.metaBuilder.buildColumnQuery('value')).then(result => {
|
||||
const task2 = this.datasource.metricFindQuery(this.metaBuilder.buildColumnQuery('value')).then((result: any) => {
|
||||
if (result.length > 0) {
|
||||
this.target.select = [[{ type: 'column', params: [result[0].text] }]];
|
||||
this.updateProjection();
|
||||
@@ -210,31 +218,33 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
|
||||
timeColumnChanged(refresh?: boolean) {
|
||||
this.target.timeColumn = this.timeColumnSegment.value;
|
||||
return this.datasource.metricFindQuery(this.metaBuilder.buildDatatypeQuery(this.target.timeColumn)).then(result => {
|
||||
if (result.length === 1) {
|
||||
if (this.target.timeColumnType !== result[0].text) {
|
||||
this.target.timeColumnType = result[0].text;
|
||||
}
|
||||
let partModel;
|
||||
if (this.queryModel.hasUnixEpochTimecolumn()) {
|
||||
partModel = sqlPart.create({ type: 'macro', name: '$__unixEpochFilter', params: [] });
|
||||
} else {
|
||||
partModel = sqlPart.create({ type: 'macro', name: '$__timeFilter', params: [] });
|
||||
return this.datasource
|
||||
.metricFindQuery(this.metaBuilder.buildDatatypeQuery(this.target.timeColumn))
|
||||
.then((result: any) => {
|
||||
if (result.length === 1) {
|
||||
if (this.target.timeColumnType !== result[0].text) {
|
||||
this.target.timeColumnType = result[0].text;
|
||||
}
|
||||
let partModel;
|
||||
if (this.queryModel.hasUnixEpochTimecolumn()) {
|
||||
partModel = sqlPart.create({ type: 'macro', name: '$__unixEpochFilter', params: [] });
|
||||
} else {
|
||||
partModel = sqlPart.create({ type: 'macro', name: '$__timeFilter', params: [] });
|
||||
}
|
||||
|
||||
if (this.whereParts.length >= 1 && this.whereParts[0].def.type === 'macro') {
|
||||
// replace current macro
|
||||
this.whereParts[0] = partModel;
|
||||
} else {
|
||||
this.whereParts.splice(0, 0, partModel);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.whereParts.length >= 1 && this.whereParts[0].def.type === 'macro') {
|
||||
// replace current macro
|
||||
this.whereParts[0] = partModel;
|
||||
} else {
|
||||
this.whereParts.splice(0, 0, partModel);
|
||||
this.updatePersistedParts();
|
||||
if (refresh !== false) {
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
this.updatePersistedParts();
|
||||
if (refresh !== false) {
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getMetricColumnSegments() {
|
||||
@@ -249,7 +259,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
|
||||
onDataReceived(dataList) {
|
||||
onDataReceived(dataList: any) {
|
||||
this.lastQueryMeta = null;
|
||||
this.lastQueryError = null;
|
||||
|
||||
@@ -259,7 +269,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
onDataError(err) {
|
||||
onDataError(err: any) {
|
||||
if (err.data && err.data.results) {
|
||||
const queryRes = err.data.results[this.target.refId];
|
||||
if (queryRes) {
|
||||
@@ -269,8 +279,8 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
transformToSegments(config) {
|
||||
return results => {
|
||||
transformToSegments(config: any) {
|
||||
return (results: any) => {
|
||||
const segments = _.map(results, segment => {
|
||||
return this.uiSegmentSrv.newSegment({
|
||||
value: segment.text,
|
||||
@@ -304,15 +314,15 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
};
|
||||
}
|
||||
|
||||
findAggregateIndex(selectParts) {
|
||||
findAggregateIndex(selectParts: any) {
|
||||
return _.findIndex(selectParts, (p: any) => p.def.type === 'aggregate' || p.def.type === 'percentile');
|
||||
}
|
||||
|
||||
findWindowIndex(selectParts) {
|
||||
findWindowIndex(selectParts: any) {
|
||||
return _.findIndex(selectParts, (p: any) => p.def.type === 'window' || p.def.type === 'moving_window');
|
||||
}
|
||||
|
||||
addSelectPart(selectParts, item, subItem) {
|
||||
addSelectPart(selectParts: any[], item: { value: any }, subItem: { type: any; value: any }) {
|
||||
let partType = item.value;
|
||||
if (subItem && subItem.type) {
|
||||
partType = subItem.type;
|
||||
@@ -384,7 +394,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
|
||||
removeSelectPart(selectParts, part) {
|
||||
removeSelectPart(selectParts: any, part: { def: { type: string } }) {
|
||||
if (part.def.type === 'column') {
|
||||
// remove all parts of column unless its last column
|
||||
if (this.selectParts.length > 1) {
|
||||
@@ -399,7 +409,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.updatePersistedParts();
|
||||
}
|
||||
|
||||
handleSelectPartEvent(selectParts, part, evt) {
|
||||
handleSelectPartEvent(selectParts: any, part: { def: any }, evt: { name: any }) {
|
||||
switch (evt.name) {
|
||||
case 'get-param-options': {
|
||||
switch (part.def.type) {
|
||||
@@ -431,7 +441,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
handleGroupPartEvent(part, index, evt) {
|
||||
handleGroupPartEvent(part: any, index: any, evt: { name: any }) {
|
||||
switch (evt.name) {
|
||||
case 'get-param-options': {
|
||||
return this.datasource
|
||||
@@ -455,7 +465,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
addGroup(partType, value) {
|
||||
addGroup(partType: string, value: string) {
|
||||
let params = [value];
|
||||
if (partType === 'time') {
|
||||
params = ['$__interval', 'none'];
|
||||
@@ -484,7 +494,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.updatePersistedParts();
|
||||
}
|
||||
|
||||
removeGroup(part, index) {
|
||||
removeGroup(part: { def: { type: string } }, index: number) {
|
||||
if (part.def.type === 'time') {
|
||||
// remove aggregations
|
||||
this.selectParts = _.map(this.selectParts, (s: any) => {
|
||||
@@ -501,7 +511,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.updatePersistedParts();
|
||||
}
|
||||
|
||||
handleWherePartEvent(whereParts, part, evt, index) {
|
||||
handleWherePartEvent(whereParts: any, part: any, evt: any, index: any) {
|
||||
switch (evt.name) {
|
||||
case 'get-param-options': {
|
||||
switch (evt.param.name) {
|
||||
@@ -567,7 +577,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
return this.$q.when(options);
|
||||
}
|
||||
|
||||
addWhereAction(part, index) {
|
||||
addWhereAction(part: any, index: number) {
|
||||
switch (this.whereAdd.type) {
|
||||
case 'macro': {
|
||||
const partModel = sqlPart.create({ type: 'macro', name: this.whereAdd.value, params: [] });
|
||||
@@ -592,7 +602,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
getGroupOptions() {
|
||||
return this.datasource
|
||||
.metricFindQuery(this.metaBuilder.buildColumnQuery('group'))
|
||||
.then(tags => {
|
||||
.then((tags: any) => {
|
||||
const options = [];
|
||||
if (!this.queryModel.hasTimeGroup()) {
|
||||
options.push(this.uiSegmentSrv.newSegment({ type: 'time', value: 'time($__interval,none)' }));
|
||||
@@ -616,7 +626,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
|
||||
handleQueryError(err) {
|
||||
handleQueryError(err: any): any[] {
|
||||
this.error = err.message || 'Failed to issue metric query';
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import _ from 'lodash';
|
||||
import { IQService } from 'angular';
|
||||
|
||||
export default class ResponseParser {
|
||||
constructor(private $q) {}
|
||||
constructor(private $q: IQService) {}
|
||||
|
||||
processQueryResult(res) {
|
||||
const data = [];
|
||||
processQueryResult(res: any) {
|
||||
const data: any[] = [];
|
||||
|
||||
if (!res.data.results) {
|
||||
return { data: data };
|
||||
@@ -37,7 +38,7 @@ export default class ResponseParser {
|
||||
return { data: data };
|
||||
}
|
||||
|
||||
parseMetricFindQueryResult(refId, results) {
|
||||
parseMetricFindQueryResult(refId: string, results: any) {
|
||||
if (!results || results.data.length === 0 || results.data.results[refId].meta.rowCount === 0) {
|
||||
return [];
|
||||
}
|
||||
@@ -54,7 +55,7 @@ export default class ResponseParser {
|
||||
return this.transformToSimpleList(rows);
|
||||
}
|
||||
|
||||
transformToKeyValueList(rows, textColIndex, valueColIndex) {
|
||||
transformToKeyValueList(rows: any, textColIndex: number, valueColIndex: number) {
|
||||
const res = [];
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
@@ -69,7 +70,7 @@ export default class ResponseParser {
|
||||
return res;
|
||||
}
|
||||
|
||||
transformToSimpleList(rows) {
|
||||
transformToSimpleList(rows: any) {
|
||||
const res = [];
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
@@ -86,7 +87,7 @@ export default class ResponseParser {
|
||||
});
|
||||
}
|
||||
|
||||
findColIndex(columns, colName) {
|
||||
findColIndex(columns: any[], colName: string) {
|
||||
for (let i = 0; i < columns.length; i++) {
|
||||
if (columns[i].text === colName) {
|
||||
return i;
|
||||
@@ -96,7 +97,7 @@ export default class ResponseParser {
|
||||
return -1;
|
||||
}
|
||||
|
||||
containsKey(res, key) {
|
||||
containsKey(res: any[], key: any) {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
if (res[i].text === key) {
|
||||
return true;
|
||||
@@ -105,7 +106,7 @@ export default class ResponseParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
transformAnnotationResponse(options, data) {
|
||||
transformAnnotationResponse(options: any, data: any) {
|
||||
const table = data.data.results[options.annotation.name].tables[0];
|
||||
|
||||
let timeColumnIndex = -1;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { MysqlDatasource } from '../datasource';
|
||||
import { CustomVariable } from 'app/features/templating/custom_variable';
|
||||
import { toUtc, dateTime } from '@grafana/ui/src/utils/moment_wrapper';
|
||||
import { BackendSrv } from 'app/core/services/backend_srv';
|
||||
|
||||
describe('MySQLDatasource', () => {
|
||||
const instanceSettings = { name: 'mysql' };
|
||||
const backendSrv = {};
|
||||
const templateSrv = {
|
||||
const templateSrv: any = {
|
||||
replace: jest.fn(text => text),
|
||||
};
|
||||
|
||||
@@ -25,11 +26,11 @@ describe('MySQLDatasource', () => {
|
||||
} as any;
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.ds = new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv, ctx.timeSrvMock);
|
||||
ctx.ds = new MysqlDatasource(instanceSettings, backendSrv as BackendSrv, {} as any, templateSrv, ctx.timeSrvMock);
|
||||
});
|
||||
|
||||
describe('When performing annotationQuery', () => {
|
||||
let results;
|
||||
let results: any;
|
||||
|
||||
const annotationName = 'MyAnno';
|
||||
|
||||
@@ -66,7 +67,7 @@ describe('MySQLDatasource', () => {
|
||||
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||
return Promise.resolve({ data: response, status: 200 });
|
||||
});
|
||||
ctx.ds.annotationQuery(options).then(data => {
|
||||
ctx.ds.annotationQuery(options).then((data: any) => {
|
||||
results = data;
|
||||
});
|
||||
});
|
||||
@@ -86,7 +87,7 @@ describe('MySQLDatasource', () => {
|
||||
});
|
||||
|
||||
describe('When performing metricFindQuery', () => {
|
||||
let results;
|
||||
let results: any;
|
||||
const query = 'select * from atable';
|
||||
const response = {
|
||||
results: {
|
||||
@@ -109,7 +110,7 @@ describe('MySQLDatasource', () => {
|
||||
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||
return Promise.resolve({ data: response, status: 200 });
|
||||
});
|
||||
ctx.ds.metricFindQuery(query).then(data => {
|
||||
ctx.ds.metricFindQuery(query).then((data: any) => {
|
||||
results = data;
|
||||
});
|
||||
});
|
||||
@@ -122,7 +123,7 @@ describe('MySQLDatasource', () => {
|
||||
});
|
||||
|
||||
describe('When performing metricFindQuery with key, value columns', () => {
|
||||
let results;
|
||||
let results: any;
|
||||
const query = 'select * from atable';
|
||||
const response = {
|
||||
results: {
|
||||
@@ -145,7 +146,7 @@ describe('MySQLDatasource', () => {
|
||||
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||
return Promise.resolve({ data: response, status: 200 });
|
||||
});
|
||||
ctx.ds.metricFindQuery(query).then(data => {
|
||||
ctx.ds.metricFindQuery(query).then((data: any) => {
|
||||
results = data;
|
||||
});
|
||||
});
|
||||
@@ -160,7 +161,7 @@ describe('MySQLDatasource', () => {
|
||||
});
|
||||
|
||||
describe('When performing metricFindQuery with key, value columns and with duplicate keys', () => {
|
||||
let results;
|
||||
let results: any;
|
||||
const query = 'select * from atable';
|
||||
const response = {
|
||||
results: {
|
||||
@@ -183,7 +184,7 @@ describe('MySQLDatasource', () => {
|
||||
ctx.backendSrv.datasourceRequest = jest.fn(options => {
|
||||
return Promise.resolve({ data: response, status: 200 });
|
||||
});
|
||||
ctx.ds.metricFindQuery(query).then(data => {
|
||||
ctx.ds.metricFindQuery(query).then((data: any) => {
|
||||
results = data;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SqlPartDef, SqlPart } from 'app/core/components/sql_part/sql_part';
|
||||
|
||||
const index = [];
|
||||
const index: any[] = [];
|
||||
|
||||
function createPart(part): any {
|
||||
function createPart(part: any): any {
|
||||
const def = index[part.type];
|
||||
if (!def) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user