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

@ -246,6 +246,10 @@ export class PostgresQueryCtrl extends QueryCtrl {
};
}
findAggregateIndex(selectParts) {
return _.findIndex(selectParts, (p: any) => p.def.type === 'aggregate' || p.def.type === 'percentile');
}
addSelectPart(selectParts, item, subItem) {
let partModel = sqlPart.create({ type: item.value });
if (subItem) {
@ -267,7 +271,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
if (this.target.group.length === 0) {
this.addGroup('time', '1m');
}
let aggIndex = _.findIndex(selectParts, (p: any) => p.def.type === 'aggregate' || p.def.type === 'percentile');
let aggIndex = this.findAggregateIndex(selectParts);
if (aggIndex !== -1) {
// replace current aggregation
selectParts[aggIndex] = partModel;
@ -284,10 +288,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
// replace current window function
selectParts[windowIndex] = partModel;
} else {
let aggIndex = _.findIndex(
selectParts,
(p: any) => p.def.type === 'aggregate' || p.def.type === 'percentile'
);
let aggIndex = this.findAggregateIndex(selectParts);
if (aggIndex !== -1) {
selectParts.splice(aggIndex + 1, 0, partModel);
} else {