mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Refactor where clause generation
This commit is contained in:
parent
5dd236bf05
commit
b9edc3c611
@ -222,18 +222,8 @@ export default class PostgresQuery {
|
||||
return query;
|
||||
}
|
||||
|
||||
buildQuery(target) {
|
||||
var query = 'SELECT ';
|
||||
|
||||
query += this.buildTimeColumn(target);
|
||||
|
||||
if (this.target.metricColumn !== 'None') {
|
||||
query += ',' + this.target.metricColumn + ' AS metric';
|
||||
}
|
||||
|
||||
query += this.buildValueColumns(target);
|
||||
|
||||
query += ' FROM ' + target.schema + '.' + target.table;
|
||||
buildWhereClause(target) {
|
||||
let query = '';
|
||||
var conditions = _.map(target.where, (tag, index) => {
|
||||
switch (tag.type) {
|
||||
case 'macro':
|
||||
@ -246,9 +236,27 @@ export default class PostgresQuery {
|
||||
});
|
||||
|
||||
if (conditions.length > 0) {
|
||||
query += ' WHERE ' + conditions.join(' AND ');
|
||||
query = ' WHERE ' + conditions.join(' AND ');
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
buildQuery(target) {
|
||||
var query = 'SELECT ';
|
||||
|
||||
query += this.buildTimeColumn(target);
|
||||
|
||||
if (this.target.metricColumn !== 'None') {
|
||||
query += ',' + this.target.metricColumn + ' AS metric';
|
||||
}
|
||||
|
||||
query += this.buildValueColumns(target);
|
||||
|
||||
query += ' FROM ' + target.schema + '.' + target.table;
|
||||
|
||||
query += this.buildWhereClause(target);
|
||||
|
||||
var groupBySection = '';
|
||||
for (let i = 0; i < this.groupByParts.length; i++) {
|
||||
var part = this.groupByParts[i];
|
||||
|
Loading…
Reference in New Issue
Block a user