From c5bde0ef457312403ac0d8790d623fc831744b10 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Wed, 11 Jul 2018 10:50:49 +0200 Subject: [PATCH] Refactor render function on PostgresQuery --- .../plugins/datasource/postgres/postgres_query.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/app/plugins/datasource/postgres/postgres_query.ts b/public/app/plugins/datasource/postgres/postgres_query.ts index 665393c8ac8..b6f00d7efbf 100644 --- a/public/app/plugins/datasource/postgres/postgres_query.ts +++ b/public/app/plugins/datasource/postgres/postgres_query.ts @@ -169,7 +169,8 @@ export default class PostgresQuery { } render(interpolate?) { - var target = this.target; + let target = this.target; + let query; if (target.rawQuery) { if (interpolate) { @@ -179,6 +180,14 @@ export default class PostgresQuery { } } + query = this.buildQuery(target); + if (interpolate) { + query = this.templateSrv.replace(query, this.scopedVars, this.interpolateQueryStr); + } + return query; + } + + buildQuery(target) { var query = 'SELECT '; var timeGroup = this.hasGroupByTime(); @@ -250,9 +259,6 @@ export default class PostgresQuery { query += ' ORDER BY 1'; this.target.rawSql = query; - if (interpolate) { - query = this.templateSrv.replace(query, this.scopedVars, this.interpolateQueryStr); - } return query; } }