Loki: Fix Loki with repeated panels and interpolation for Explore (#21685)

This commit is contained in:
Ivana Huckova
2020-01-24 09:50:09 +01:00
committed by GitHub
parent f91a495875
commit e75840737e
11 changed files with 40 additions and 22 deletions

View File

@ -2,6 +2,7 @@ import _ from 'lodash';
import ResponseParser from './response_parser';
import PostgresQuery from 'app/plugins/datasource/postgres/postgres_query';
import { getBackendSrv } from '@grafana/runtime';
import { ScopedVars } from '@grafana/data';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
//Types
@ -49,14 +50,17 @@ export class PostgresDatasource {
return quotedValues.join(',');
};
interpolateVariablesInQueries(queries: PostgresQueryForInterpolation[]): PostgresQueryForInterpolation[] {
interpolateVariablesInQueries(
queries: PostgresQueryForInterpolation[],
scopedVars: ScopedVars
): PostgresQueryForInterpolation[] {
let expandedQueries = queries;
if (queries && queries.length > 0) {
expandedQueries = queries.map(query => {
const expandedQuery = {
...query,
datasource: this.name,
rawSql: this.templateSrv.replace(query.rawSql, {}, this.interpolateVariable),
rawSql: this.templateSrv.replace(query.rawSql, scopedVars, this.interpolateVariable),
};
return expandedQuery;
});