v3 prisma queries update

This commit is contained in:
Francis Cao 2025-10-27 11:48:35 -07:00
parent 61b667c587
commit 2ffde37f5b
21 changed files with 119 additions and 108 deletions

View file

@ -21,20 +21,23 @@ async function relationalQuery(websiteId: string, sessionId: string, filters: Qu
return rawQuery(
`
select
created_at as createdAt,
url_path as urlPath,
url_query as urlQuery,
referrer_domain as referrerDomain,
event_id as eventId,
event_type as eventType,
event_name as eventName,
visit_id as visitId,
event_id IN (SELECT event_id FROM event_data) AS hasData
from website_event e
where e.website_id = {websiteId:UUID}
and e.session_id = {sessionId:UUID}
and e.created_at between {startDate:DateTime64} and {endDate:DateTime64}
order by e.created_at desc
created_at as "createdAt",
url_path as "urlPath",
url_query as "urlQuery",
referrer_domain as "referrerDomain",
event_id as "eventId",
event_type as "eventType",
event_name as "eventName",
visit_id as "visitId",
event_id IN (select event_id
from event_data
where website_id = {{websiteId::uuid}}
and session_id = {{sessionId::uuid}}) AS "hasData"
from website_event
where website_id = {{websiteId::uuid}}
and session_id = {{sessionId::uuid}}
and created_at between {{startDate}} and {{endDate}}
order by created_at desc
limit 500
`,
{ websiteId, sessionId, startDate, endDate },

View file

@ -31,6 +31,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
${joinSessionQuery}
join session_data
on session_data.session_id = website_event.session_id
and session_data.website_id = website_event.website_id
where website_event.website_id = {{websiteId::uuid}}
and website_event.created_at between {{startDate}} and {{endDate}}
${filterQuery}

View file

@ -38,6 +38,7 @@ async function relationalQuery(
${joinSessionQuery}
join session_data
on session_data.session_id = website_event.session_id
and session_data.website_id = website_event.website_id
where website_event.website_id = {{websiteId::uuid}}
and website_event.created_at between {{startDate}} and {{endDate}}
and session_data.data_key = {{propertyName}}

View file

@ -44,6 +44,7 @@ async function relationalQuery(
from website_event
${cohortQuery}
join session on website_event.session_id = session.session_id
and website_event.website_id = session.website_id
where website_event.website_id = {{websiteId::uuid}}
and website_event.created_at between {{startDate}} and {{endDate}}
${filterQuery}

View file

@ -52,6 +52,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
from website_event
${cohortQuery}
join session on session.session_id = website_event.session_id
and session.website_id = website_event.website_id
where website_event.website_id = {{websiteId::uuid}}
${dateQuery}
${filterQuery}