mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
update funnels relational query
This commit is contained in:
parent
25feee662b
commit
94967d45e1
2 changed files with 46 additions and 31 deletions
|
|
@ -34,7 +34,7 @@ async function relationalQuery(
|
|||
}[]
|
||||
> {
|
||||
const { windowMinutes, startDate, endDate, urls } = criteria;
|
||||
const { rawQuery, getFunnelQuery, toUuid } = prisma;
|
||||
const { rawQuery, getFunnelQuery, toUuid, getDropoffQuery } = prisma;
|
||||
const { levelQuery, sumQuery, urlFilterQuery } = getFunnelQuery(urls, windowMinutes);
|
||||
|
||||
const params: any = [websiteId, startDate, endDate, ...urls];
|
||||
|
|
@ -47,14 +47,18 @@ async function relationalQuery(
|
|||
and website_id = $1${toUuid()}
|
||||
and created_at between $2 and $3
|
||||
),level1 AS (
|
||||
select distinct session_id, url_path as level_1_url, created_at as level_1_created_at
|
||||
select distinct session_id, created_at
|
||||
from level0
|
||||
where url_path = $4
|
||||
)${levelQuery}
|
||||
|
||||
SELECT ${sumQuery}
|
||||
from level${urls.length};
|
||||
`,
|
||||
)${levelQuery}, levelCount as (
|
||||
${sumQuery}
|
||||
order by level)
|
||||
select
|
||||
level,
|
||||
count,
|
||||
${getDropoffQuery()} as drop_off
|
||||
from levelCount;
|
||||
`,
|
||||
params,
|
||||
).then((a: { [key: string]: number }) => {
|
||||
return urls.map((b, i) => ({ x: b, y: a[0][`level${i + 1}`] || 0 }));
|
||||
|
|
@ -77,7 +81,7 @@ async function clickhouseQuery(
|
|||
> {
|
||||
const { windowMinutes, startDate, endDate, urls } = criteria;
|
||||
const { rawQuery, getBetweenDates, getFunnelQuery } = clickhouse;
|
||||
const { columnsQuery, conditionQuery, urlParams } = getFunnelQuery(urls);
|
||||
const { columnsQuery, urlParams } = getFunnelQuery(urls);
|
||||
|
||||
const params = {
|
||||
websiteId,
|
||||
|
|
@ -87,22 +91,22 @@ async function clickhouseQuery(
|
|||
|
||||
return rawQuery<{ level: number; count: number }[]>(
|
||||
`
|
||||
SELECT level,
|
||||
select level,
|
||||
count(*) AS count
|
||||
FROM (
|
||||
SELECT session_id,
|
||||
from (
|
||||
select session_id,
|
||||
windowFunnel({window:UInt32}, 'strict_increase')
|
||||
(
|
||||
created_at
|
||||
${columnsQuery}
|
||||
) AS level
|
||||
FROM website_event
|
||||
WHERE website_id = {websiteId:UUID}
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
GROUP BY 1
|
||||
group by 1
|
||||
)
|
||||
GROUP BY level
|
||||
ORDER BY level ASC;
|
||||
group by level
|
||||
order by level asc;
|
||||
`,
|
||||
params,
|
||||
).then(results => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue