mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 06:07:17 +01:00
v3 prisma queries update
This commit is contained in:
parent
61b667c587
commit
2ffde37f5b
21 changed files with 119 additions and 108 deletions
|
|
@ -69,14 +69,14 @@ async function relationalQuery(
|
|||
|
||||
const eventQuery = `WITH events AS (
|
||||
select distinct
|
||||
session_id,
|
||||
max(created_at) max_dt
|
||||
website_event.session_id,
|
||||
max(website_event.created_at) max_dt
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
and ${column} = {{step}}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and website_event.${column} = {{step}}
|
||||
${filterQuery}
|
||||
group by 1),`;
|
||||
|
||||
|
|
@ -234,14 +234,14 @@ async function relationalQuery(
|
|||
`
|
||||
select
|
||||
count(*) as "pageviews",
|
||||
count(distinct session_id) as "visitors",
|
||||
count(distinct visit_id) as "visits"
|
||||
count(distinct website_event.session_id) as "visitors",
|
||||
count(distinct website_event.visit_id) as "visits"
|
||||
from website_event
|
||||
${joinSessionQuery}
|
||||
${cohortQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
and ${column} = {{step}}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and website_event.${column} = {{step}}
|
||||
${filterQuery}
|
||||
`,
|
||||
queryParams,
|
||||
|
|
|
|||
|
|
@ -67,12 +67,12 @@ async function relationalQuery(
|
|||
if (levelNumber === 1) {
|
||||
pv.levelOneQuery = `
|
||||
WITH level1 AS (
|
||||
select distinct session_id, created_at
|
||||
select distinct website_event.session_id, website_event.created_at
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and ${column} ${operator} {{${i}}}
|
||||
${filterQuery}
|
||||
)`;
|
||||
|
|
|
|||
|
|
@ -42,26 +42,26 @@ async function relationalQuery(
|
|||
|
||||
return rawQuery(
|
||||
`
|
||||
select count(*) as num,
|
||||
select count(distinct website_event.session_id) as num,
|
||||
(
|
||||
select count(distinct session_id)
|
||||
select count(distinct website_event.session_id)
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
${dateQuery}
|
||||
${filterQuery}
|
||||
) as total
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and ${column} = {{value}}
|
||||
${dateQuery}
|
||||
${filterQuery}
|
||||
`,
|
||||
queryParams,
|
||||
);
|
||||
).then(results => results?.[0]);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(
|
||||
|
|
@ -84,7 +84,7 @@ async function clickhouseQuery(
|
|||
|
||||
return rawQuery(
|
||||
`
|
||||
select count(*) as num,
|
||||
select count(distinct session_id) as num,
|
||||
(
|
||||
select count(distinct session_id)
|
||||
from website_event
|
||||
|
|
|
|||
|
|
@ -117,16 +117,16 @@ async function relationalQuery(
|
|||
`
|
||||
WITH events AS (
|
||||
select distinct
|
||||
visit_id,
|
||||
referrer_path,
|
||||
coalesce(nullIf(event_name, ''), url_path) event,
|
||||
row_number() OVER (PARTITION BY visit_id ORDER BY created_at) AS event_number
|
||||
website_event.visit_id,
|
||||
website_event.referrer_path,
|
||||
coalesce(nullIf(website_event.event_name, ''), website_event.url_path) event,
|
||||
row_number() OVER (PARTITION BY visit_id ORDER BY website_event.created_at) AS event_number
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}),
|
||||
${filterQuery}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
${filterQuery}),
|
||||
${sequenceQuery}
|
||||
select *
|
||||
from sequences
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ async function relationalQuery(
|
|||
|
||||
return rawQuery(
|
||||
`
|
||||
select ${column} utm, count(*) as views
|
||||
select website_event.${column} utm, count(*) as views
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
${joinSessionQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
and coalesce(${column}, '') != ''
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||
and coalesce(website_event.${column}, '') != ''
|
||||
${filterQuery}
|
||||
group by 1
|
||||
order by 2 desc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue