mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
Refactor metric column sql generation
This commit is contained in:
parent
a86e77fc68
commit
9ba42f63f1
@ -184,6 +184,7 @@ export default class PostgresQuery {
|
||||
if (interpolate) {
|
||||
query = this.templateSrv.replace(query, this.scopedVars, this.interpolateQueryStr);
|
||||
}
|
||||
this.target.rawSql = query;
|
||||
return query;
|
||||
}
|
||||
|
||||
@ -206,6 +207,16 @@ export default class PostgresQuery {
|
||||
return query;
|
||||
}
|
||||
|
||||
buildMetricColumn(target) {
|
||||
let query = '';
|
||||
|
||||
if (this.target.metricColumn !== 'None') {
|
||||
query += ',' + this.target.metricColumn + ' AS metric';
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
buildValueColumns(target) {
|
||||
let query = '';
|
||||
for (let i = 0; i < this.selectModels.length; i++) {
|
||||
@ -271,11 +282,7 @@ export default class PostgresQuery {
|
||||
let query = 'SELECT ';
|
||||
|
||||
query += this.buildTimeColumn(target);
|
||||
|
||||
if (this.target.metricColumn !== 'None') {
|
||||
query += ',' + this.target.metricColumn + ' AS metric';
|
||||
}
|
||||
|
||||
query += this.buildMetricColumn(target);
|
||||
query += this.buildValueColumns(target);
|
||||
|
||||
query += ' FROM ' + target.schema + '.' + target.table;
|
||||
@ -285,7 +292,6 @@ export default class PostgresQuery {
|
||||
|
||||
query += ' ORDER BY 1';
|
||||
|
||||
this.target.rawSql = query;
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user