Insights report filters.

This commit is contained in:
Mike Cao 2023-08-09 15:06:19 -07:00
parent acbffed2ce
commit 5039349d57
7 changed files with 138 additions and 87 deletions

View file

@ -45,7 +45,7 @@ async function relationalQuery(
and website_event.created_at between {{startDate}} and {{endDate}}
and website_event.event_type = {{eventType}}
${filterQuery}
group by ${fields.map(({ name }) => name).join(',')}
${parseGroupBy(fields)}
order by 1 desc, 2 desc
limit 500
`,
@ -78,7 +78,7 @@ async function clickhouseQuery(
and created_at between {startDate:DateTime} and {endDate:DateTime}
and event_type = {eventType:UInt32}
${filterQuery}
group by ${fields.map(({ name }) => name).join(',')}
${parseGroupBy(fields)}
order by 1 desc, 2 desc
limit 500
`,
@ -98,3 +98,10 @@ function parseFields(fields) {
return query.join(',\n');
}
function parseGroupBy(fields) {
if (!fields.length) {
return '';
}
return `group by ${fields.map(({ name }) => name).join(',')}`;
}