add aggregates when adding group by

This commit is contained in:
Sven Klemm 2018-07-10 11:14:00 +02:00
parent 483e7c0163
commit 6e7161f238

View File

@ -96,6 +96,14 @@ export default class PostgresQuery {
partModel.part.params = ['1m', 'none'];
}
// add aggregates when adding group by
for (let i = 0; i < this.target.select.length; i++) {
var selectParts = this.target.select[i];
if (!selectParts.some(part => part.type === 'aggregate')) {
selectParts.splice(1, 0, { type: 'aggregate', params: ['avg'] });
}
}
this.updateProjection();
}