fix clickhouse calls (#1536)

This commit is contained in:
Brian Cao 2022-09-23 22:43:51 -07:00 committed by GitHub
parent dfac7e1af5
commit 78c3453639
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 41 additions and 34 deletions

View file

@ -43,7 +43,7 @@ async function clickhouseQuery(website_id, { startDate, endDate, column, filters
`select ${column} x, count(*) y
from event
where website_id= $1
${column !== 'event_name' ? `and event_name = ''` : ''}
${column !== 'event_name' ? `and event_name = ''` : `and event_name != ''`}
and ${getBetweenDates('created_at', startDate, endDate)}
${pageviewQuery}
${sessionQuery}

View file

@ -59,10 +59,10 @@ async function clickhouseQuery(
from
(select
${getDateQuery('created_at', unit, timezone)} t,
count(${count !== '*' ? 'session_uuid' : count}) y
count(${count !== '*' ? 'distinct session_uuid' : count}) y
from event
where website_id= $1
where event_name = ''
and website_id= $1
and ${getBetweenDates('created_at', start_at, end_at)}
${pageviewQuery}
${sessionQuery}

View file

@ -33,7 +33,7 @@ async function clickhouseQuery(websites, start_at) {
url
from event
where event_name = ''
and website_id in (${websites.join[',']}
and created_at >= ${clickhouse.getDateFormat(start_at)})`,
and ${websites && websites.length > 0 ? `website_id in (${websites.join(',')})` : '0 = 0'}
and created_at >= ${clickhouse.getDateFormat(start_at)}`,
);
}