mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Fix funnel report.
This commit is contained in:
parent
56f3134936
commit
414854b064
@ -137,12 +137,13 @@ function getFilterQuery(filters = {}, params = []): string {
|
||||
function getFunnelQuery(
|
||||
urls: string[],
|
||||
windowMinutes: number,
|
||||
initParamLength = 3,
|
||||
): {
|
||||
levelQuery: string;
|
||||
sumQuery: string;
|
||||
urlFilterQuery: string;
|
||||
} {
|
||||
const initParamLength = 3;
|
||||
|
||||
return urls.reduce(
|
||||
(pv, cv, i) => {
|
||||
const levelNumber = i + 1;
|
||||
@ -155,12 +156,14 @@ function getFunnelQuery(
|
||||
l0.created_at level_${levelNumber}_created_at,
|
||||
l0.url_path as level_${levelNumber}_url
|
||||
from level${i} cl
|
||||
left join level0 l0
|
||||
left join website_event l0
|
||||
on cl.session_id = l0.session_id
|
||||
and l0.created_at between cl.level_${i}_created_at
|
||||
and ${getAddMinutesQuery(`cl.level_${i}_created_at`, windowMinutes)}
|
||||
and l0.referrer_path = $${i + initParamLength}
|
||||
and l0.url_path = $${levelNumber + initParamLength}
|
||||
and created_at between $2 and $3
|
||||
and website_id = $1${toUuid()}
|
||||
)`;
|
||||
}
|
||||
|
||||
|
@ -41,23 +41,23 @@ async function relationalQuery(
|
||||
|
||||
return rawQuery(
|
||||
`WITH level0 AS (
|
||||
select session_id, url_path, referrer_path, created_at
|
||||
select distinct session_id, url_path, referrer_path, created_at
|
||||
from website_event
|
||||
where url_path in (${urlFilterQuery})
|
||||
and website_id = $1${toUuid()}
|
||||
and created_at between $2 and $3
|
||||
),level1 AS (
|
||||
select session_id, url_path as level_1_url, created_at as level_1_created_at
|
||||
select distinct session_id, url_path as level_1_url, created_at as level_1_created_at
|
||||
from level0
|
||||
where url_path = $4
|
||||
)${levelQuery}
|
||||
|
||||
SELECT ${sumQuery}
|
||||
from level3;
|
||||
from level${urls.length};
|
||||
`,
|
||||
params,
|
||||
).then((a: { [key: string]: number }) => {
|
||||
return urls.map((b, i) => ({ x: b, y: a[`level${i + 1}`] || 0 }));
|
||||
return urls.map((b, i) => ({ x: b, y: a[0][`level${i + 1}`] || 0 }));
|
||||
});
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ async function clickhouseQuery(
|
||||
count(*) AS count
|
||||
FROM (
|
||||
SELECT session_id,
|
||||
windowFunnel({window:UInt32}, 'strict_order')
|
||||
windowFunnel({window:UInt32})
|
||||
(
|
||||
created_at
|
||||
${columnsQuery}
|
||||
@ -99,7 +99,6 @@ async function clickhouseQuery(
|
||||
FROM website_event
|
||||
WHERE website_id = {websiteId:UUID}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
AND (url_path in [${conditionQuery}])
|
||||
GROUP BY 1
|
||||
)
|
||||
GROUP BY level
|
||||
|
Loading…
Reference in New Issue
Block a user