rename special to windows

This commit is contained in:
Sven Klemm
2018-07-29 15:56:22 +02:00
parent 26ea88252b
commit ace999b13f
2 changed files with 11 additions and 10 deletions

View File

@ -135,7 +135,7 @@ export default class PostgresQuery {
query = columnName.params[0];
let aggregate = _.find(column, (g: any) => g.type === 'aggregate' || g.type === 'percentile');
let special = _.find(column, (g: any) => g.type === 'window');
let windows = _.find(column, (g: any) => g.type === 'window');
if (aggregate) {
let func = aggregate.params[0];
@ -144,7 +144,7 @@ export default class PostgresQuery {
if (func === 'first' || func === 'last') {
query = func + '(' + query + ',' + this.target.timeColumn + ')';
} else {
if (special) {
if (windows) {
query = func + '(' + query + ' ORDER BY ' + this.target.timeColumn + ')';
} else {
query = func + '(' + query + ')';
@ -157,7 +157,7 @@ export default class PostgresQuery {
}
}
if (special) {
if (windows) {
let overParts = [];
if (this.hasMetricColumn()) {
overParts.push('PARTITION BY ' + this.target.metricColumn);
@ -169,7 +169,7 @@ export default class PostgresQuery {
let over = overParts.join(' ');
let curr: string;
let prev: string;
switch (special.params[0]) {
switch (windows.params[0]) {
case 'increase':
curr = query;
prev = 'lag(' + curr + ') OVER (' + over + ')';
@ -187,7 +187,7 @@ export default class PostgresQuery {
query += '/extract(epoch from ' + timeColumn + ' - lag(' + timeColumn + ') OVER (' + over + '))';
break;
default:
query = special.params[0] + '(' + query + ') OVER (' + over + ')';
query = windows.params[0] + '(' + query + ') OVER (' + over + ')';
break;
}
}