noImplicitAny: Sub 3000 errors (#17821)

* noImplicitAny Stackdriver

* Sub 3000 noImplicitAny

* Update error count limit

* Add DataQueryRequest type
This commit is contained in:
Tobias Skarhed
2019-07-01 11:11:57 +02:00
committed by Torkel Ödegaard
parent bd4a7ddf3a
commit 4e27ba9646
38 changed files with 388 additions and 302 deletions

View File

@ -5,6 +5,8 @@ import { QueryCtrl } from 'app/plugins/sdk';
import { SqlPart } from 'app/core/components/sql_part/sql_part';
import PostgresQuery from './postgres_query';
import sqlPart from './sql_part';
import { auto, IQService } from 'angular';
import { TemplateSrv } from 'app/features/templating/template_srv';
export interface QueryMeta {
sql: string;
@ -40,7 +42,13 @@ export class PostgresQueryCtrl 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;
this.queryModel = new PostgresQuery(this.target, templateSrv, this.panel.scopedVars);
@ -57,7 +65,7 @@ export class PostgresQueryCtrl 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);
@ -187,7 +195,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
}
}
resetPlusButton(button) {
resetPlusButton(button: { html: any; value: any }) {
const plusButton = this.uiSegmentSrv.newPlusButton();
button.html = plusButton.html;
button.value = plusButton.value;
@ -211,7 +219,7 @@ export class PostgresQueryCtrl 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);
@ -220,7 +228,7 @@ export class PostgresQueryCtrl 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();
@ -241,31 +249,33 @@ export class PostgresQueryCtrl 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() {
@ -280,7 +290,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
this.panelCtrl.refresh();
}
onDataReceived(dataList) {
onDataReceived(dataList: any) {
this.lastQueryMeta = null;
this.lastQueryError = null;
@ -290,7 +300,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
}
}
onDataError(err) {
onDataError(err: any) {
if (err.data && err.data.results) {
const queryRes = err.data.results[this.target.refId];
if (queryRes) {
@ -300,8 +310,8 @@ export class PostgresQueryCtrl extends QueryCtrl {
}
}
transformToSegments(config) {
return results => {
transformToSegments(config: { addNone?: any; addTemplateVars?: any; templateQuoter?: any }) {
return (results: any) => {
const segments = _.map(results, segment => {
return this.uiSegmentSrv.newSegment({
value: segment.text,
@ -335,15 +345,15 @@ export class PostgresQueryCtrl 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;
@ -415,7 +425,7 @@ export class PostgresQueryCtrl 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) {
@ -430,7 +440,7 @@ export class PostgresQueryCtrl 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) {
@ -462,7 +472,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
}
}
handleGroupPartEvent(part, index, evt) {
handleGroupPartEvent(part: any, index: any, evt: { name: any }) {
switch (evt.name) {
case 'get-param-options': {
return this.datasource
@ -486,7 +496,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
}
}
addGroup(partType, value) {
addGroup(partType: string, value: string) {
let params = [value];
if (partType === 'time') {
params = ['$__interval', 'none'];
@ -515,7 +525,7 @@ export class PostgresQueryCtrl 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) => {
@ -532,7 +542,7 @@ export class PostgresQueryCtrl 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) {
@ -598,7 +608,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
return this.$q.when(options);
}
addWhereAction(part, index) {
addWhereAction(part: any, index: any) {
switch (this.whereAdd.type) {
case 'macro': {
const partModel = sqlPart.create({ type: 'macro', name: this.whereAdd.value, params: [] });
@ -623,7 +633,7 @@ export class PostgresQueryCtrl 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)' }));
@ -647,7 +657,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
this.panelCtrl.refresh();
}
handleQueryError(err) {
handleQueryError(err: any): any[] {
this.error = err.message || 'Failed to issue metric query';
return [];
}