Fixed pageviews query. Closes #3162

This commit is contained in:
Mike Cao 2025-02-11 08:16:40 -08:00
parent f48ca7f77a
commit 9cc648e589
3 changed files with 8 additions and 11 deletions

View file

@ -75,7 +75,7 @@
"@react-spring/web": "^9.7.3",
"@tanstack/react-query": "^5.28.6",
"@umami/prisma-client": "^0.14.0",
"@umami/redis-client": "^0.25.0",
"@umami/redis-client": "^0.26.0",
"bcryptjs": "^2.4.3",
"chalk": "^4.1.1",
"chart.js": "^4.4.2",

View file

@ -96,14 +96,14 @@ async function clickhouseQuery(
eventType: column === 'event_name' ? EVENT_TYPE.customEvent : EVENT_TYPE.pageView,
});
let excludeDomain = '';
let sql = '';
let excludeDomain = '';
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item))) {
let entryExitQuery = '';
if (column === 'referrer_domain') {
excludeDomain = `and referrer_domain != hostname and referrer_domain != ''`;
excludeDomain = `and referrer_domain != hostname and hostname != '' and referrer_domain != ''`;
}
if (type === 'entry' || type === 'exit') {
@ -115,7 +115,6 @@ async function clickhouseQuery(
from website_event
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
and event_type = {eventType:UInt32}
group by visit_id) x
ON x.visit_id = website_event.visit_id
and x.target_created_at = website_event.created_at`;
@ -127,7 +126,6 @@ async function clickhouseQuery(
${entryExitQuery}
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
and event_type = {eventType:UInt32}
${excludeDomain}
${filterQuery}
group by x
@ -139,7 +137,7 @@ async function clickhouseQuery(
let groupByQuery = '';
if (column === 'referrer_domain') {
excludeDomain = `and t != hostname`;
excludeDomain = `and t != hostname and hostname != ''`;
}
let columnQuery = `arrayJoin(${column})`;
@ -164,7 +162,6 @@ async function clickhouseQuery(
from website_event_stats_hourly website_event
where website_id = {websiteId:UUID}
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
and event_type = {eventType:UInt32}
${excludeDomain}
${filterQuery}
${groupByQuery}) as g

View file

@ -3417,10 +3417,10 @@
chalk "^4.1.2"
debug "^4.3.4"
"@umami/redis-client@^0.25.0":
version "0.25.0"
resolved "https://registry.yarnpkg.com/@umami/redis-client/-/redis-client-0.25.0.tgz#8bf01f22ceb3b90e15e59ab8daf44f838b83a6a7"
integrity sha512-j2GUehtrUfNPuikmcVXucgnL04gQOtbLiG20NqdlUXlDA/ebkV/waDfcYtMLuvXOFwiEeTatqPFEfXYuLDwJWw==
"@umami/redis-client@^0.26.0":
version "0.26.0"
resolved "https://registry.yarnpkg.com/@umami/redis-client/-/redis-client-0.26.0.tgz#0476e903a30322a43247dc292003224686971c12"
integrity sha512-j2vxb1gYF5zfk7BkrHgau2MwKsB5ijbQh2w1WoIvbP41cqTMsFm/zUrjhZ0cP1ZxR/riQR1AWxKmqNggYRZ5eA==
dependencies:
debug "^4.3.4"
redis "^4.5.1"