mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
fix excludeBounce bug when selecting page filter. Use more performant sumIF
Some checks are pending
Node.js CI / build (push) Waiting to run
Some checks are pending
Node.js CI / build (push) Waiting to run
This commit is contained in:
parent
0cd63049ed
commit
fdb99607bc
1 changed files with 8 additions and 3 deletions
|
|
@ -34,13 +34,16 @@ async function relationalQuery(
|
||||||
websiteId,
|
websiteId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { excludeBounce } = filters;
|
||||||
|
const bounceQuery = excludeBounce ? '0' : 'coalesce(sum(case when t.c = 1 then 1 else 0 end), 0)';
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
cast(coalesce(sum(t.c), 0) as bigint) as "pageviews",
|
cast(coalesce(sum(t.c), 0) as bigint) as "pageviews",
|
||||||
count(distinct t.session_id) as "visitors",
|
count(distinct t.session_id) as "visitors",
|
||||||
count(distinct t.visit_id) as "visits",
|
count(distinct t.visit_id) as "visits",
|
||||||
coalesce(sum(case when t.c = 1 then 1 else 0 end), 0) as "bounces",
|
${bounceQuery} as "bounces",
|
||||||
cast(coalesce(sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}), 0) as bigint) as "totaltime"
|
cast(coalesce(sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}), 0) as bigint) as "totaltime"
|
||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
|
|
@ -77,6 +80,8 @@ async function clickhouseQuery(
|
||||||
});
|
});
|
||||||
|
|
||||||
let sql = '';
|
let sql = '';
|
||||||
|
const { excludeBounce } = filters;
|
||||||
|
const bounceQuery = excludeBounce ? '0' : 'sumIf(1, t.c = 1)';
|
||||||
|
|
||||||
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item))) {
|
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item))) {
|
||||||
sql = `
|
sql = `
|
||||||
|
|
@ -84,7 +89,7 @@ async function clickhouseQuery(
|
||||||
sum(t.c) as "pageviews",
|
sum(t.c) as "pageviews",
|
||||||
uniq(t.session_id) as "visitors",
|
uniq(t.session_id) as "visitors",
|
||||||
uniq(t.visit_id) as "visits",
|
uniq(t.visit_id) as "visits",
|
||||||
sum(if(t.c = 1, 1, 0)) as "bounces",
|
${bounceQuery} as "bounces",
|
||||||
sum(max_time-min_time) as "totaltime"
|
sum(max_time-min_time) as "totaltime"
|
||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
|
|
@ -109,7 +114,7 @@ async function clickhouseQuery(
|
||||||
sum(t.c) as "pageviews",
|
sum(t.c) as "pageviews",
|
||||||
uniq(session_id) as "visitors",
|
uniq(session_id) as "visitors",
|
||||||
uniq(visit_id) as "visits",
|
uniq(visit_id) as "visits",
|
||||||
sumIf(1, t.c = 1) as "bounces",
|
${bounceQuery} as "bounces",
|
||||||
sum(max_time-min_time) as "totaltime"
|
sum(max_time-min_time) as "totaltime"
|
||||||
from (select
|
from (select
|
||||||
session_id,
|
session_id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue