This commit is contained in:
Brian Cao 2022-10-11 19:37:38 -07:00
parent b0bed5e73a
commit c147742d7a
18 changed files with 84 additions and 52 deletions

View file

@ -23,11 +23,13 @@ async function relationalQuery(
return rawQuery(
`select
event_name x,
${getDateQuery('created_at', unit, timezone)} t,
${getDateQuery('event.created_at', unit, timezone)} t,
count(*) y
from event
where website_id=$1
and created_at between $2 and $3
join website
on event.website_id = website.website_id
where website_uuid='${websiteId}'
and event.created_at between $2 and $3
${getFilterQuery('event', filters, params)}
group by 1, 2
order by 2`,

View file

@ -22,8 +22,9 @@ async function relationalQuery(websiteId, { startDate, endDate, column, table, f
return rawQuery(
`select ${column} x, count(*) y
from ${table}
${` join website on ${table}.website_id = website.website_id`}
${joinSession}
where ${table}.website_id=$1
where website.website_uuid='${websiteId}'
and ${table}.created_at between $2 and $3
${pageviewQuery}
${joinSession && sessionQuery}

View file

@ -22,8 +22,9 @@ async function relationalQuery(websiteId, start_at, end_at, column, table, filte
`select url x,
count(*) y
from ${table}
${` join website on ${table}.website_id = website.website_id`}
${joinSession}
where ${table}.website_id=$1
where website.website_uuid='${websiteId}'
and ${table}.created_at between $2 and $3
and ${table}.url like '%?%'
${pageviewQuery}

View file

@ -34,8 +34,10 @@ async function relationalQuery(
`select ${getDateQuery('pageview.created_at', unit, timezone)} t,
count(${count !== '*' ? `${count}${sessionKey}` : count}) y
from pageview
join website
on pageview.website_id = website.website_id
${joinSession}
where pageview.website_id=$1
where website.website_uuid='${websiteId}'
and pageview.created_at between $2 and $3
${pageviewQuery}
${sessionQuery}

View file

@ -20,8 +20,10 @@ async function relationalQuery(websiteId, { startDate, endDate, field, filters =
where x.session_id in (
select pageview.session_id
from pageview
join website
on pageview.website_id = website.website_id
${joinSession}
where pageview.website_id=$1
where website.website_uuid='${websiteId}'
and pageview.created_at between $2 and $3
${pageviewQuery}
${sessionQuery}

View file

@ -17,8 +17,10 @@ async function relationalQuery(websiteId) {
return prisma.rawQuery(
`select count(distinct session_id) x
from pageview
where website_id = $1
and created_at >= $2`,
join website
on pageview.website_id = website.website_id
where website.website_uuid = '${websiteId}'
and pageview.created_at >= $2`,
params,
);
}

View file

@ -30,11 +30,13 @@ async function relationalQuery(websiteId, { start_at, end_at, filters = {} }) {
count(*) c,
${getTimestampInterval('pageview.created_at')} as "time"
from pageview
join website
on pageview.website_id = website.website_id
${joinSession}
where pageview.website_id=$1
and pageview.created_at between $2 and $3
${pageviewQuery}
${sessionQuery}
where website.website_uuid='${websiteId}'
and pageview.created_at between $2 and $3
${pageviewQuery}
${sessionQuery}
group by 1, 2
) t`,
params,