add group by statement to queries if provided by layout

pull/10616/head
Jade McGough 2016-11-07 22:51:29 -08:00
parent 530631905d
commit 1ffa00dc16
1 changed files with 4 additions and 0 deletions

View File

@ -16,6 +16,7 @@ export const LayoutRenderer = React.createClass({
rp: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
database: PropTypes.string.isRequired,
groupBys: PropTypes.arrayOf(PropTypes.string),
}).isRequired
).isRequired,
x: PropTypes.number.isRequired,
@ -43,6 +44,9 @@ export const LayoutRenderer = React.createClass({
return this.props.cells.map((cell) => {
const qs = cell.queries.map((q) => {
_.merge(q, {host: source});
if (q.groupBys && q.groupBys.length > 0) {
q.text += ` group by ${q.groupBys.join(' ')}`;
}
q.text += ` where host = '${host}' and time > ${timeRange}`;
return q;
});