WebsiteId query param. Fix Prisma filters.
This commit is contained in:
@@ -34,8 +34,9 @@ async function relationalQuery(
|
||||
},
|
||||
) {
|
||||
const { startDate, endDate, column, filters = {}, type } = data;
|
||||
const { rawQuery, parseFilters } = prisma;
|
||||
const { rawQuery, parseFilters, toUuid } = prisma;
|
||||
const params: any = [
|
||||
websiteId,
|
||||
startDate,
|
||||
endDate,
|
||||
type === 'event' ? EVENT_TYPE.customEvent : EVENT_TYPE.pageView,
|
||||
@@ -46,9 +47,9 @@ async function relationalQuery(
|
||||
`select ${column} x, count(*) y
|
||||
from website_event
|
||||
${joinSession}
|
||||
where website_id='${websiteId}'
|
||||
and website_event.created_at between $1 and $2
|
||||
and event_type = $3
|
||||
where website_event.website_id = $1${toUuid()}
|
||||
and website_event.created_at between $2 and $3
|
||||
and event_type = $4
|
||||
${filterQuery}
|
||||
group by 1
|
||||
order by 2 desc`,
|
||||
|
||||
@@ -45,8 +45,8 @@ async function relationalQuery(
|
||||
filters = {},
|
||||
sessionKey = 'session_id',
|
||||
} = data;
|
||||
const { getDateQuery, parseFilters, rawQuery } = prisma;
|
||||
const params = [startDate, endDate];
|
||||
const { toUuid, getDateQuery, parseFilters, rawQuery } = prisma;
|
||||
const params: any = [websiteId, startDate, endDate];
|
||||
const { filterQuery, joinSession } = parseFilters(filters, params);
|
||||
|
||||
return rawQuery(
|
||||
@@ -54,8 +54,8 @@ async function relationalQuery(
|
||||
count(${count !== '*' ? `${count}${sessionKey}` : count}) y
|
||||
from website_event
|
||||
${joinSession}
|
||||
where website.website_id='${websiteId}'
|
||||
and pageview.created_at between $1 and $2
|
||||
where website_event.website_id = $1${toUuid()}
|
||||
and website_event.created_at between $2 and $3
|
||||
and event_type = ${EVENT_TYPE.pageView}
|
||||
${filterQuery}
|
||||
group by 1`,
|
||||
@@ -90,7 +90,7 @@ async function clickhouseQuery(
|
||||
${getDateQuery('created_at', unit, timezone)} t,
|
||||
count(${count !== '*' ? 'distinct session_id' : count}) y
|
||||
from event
|
||||
where website_id = $1
|
||||
where website_id = $1
|
||||
and rev_id = $2
|
||||
and event_type = ${EVENT_TYPE.pageView}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
|
||||
Reference in New Issue
Block a user