mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 06:07:17 +01:00
implement visit duration
This commit is contained in:
parent
fc758745dc
commit
f9c7129a3e
2 changed files with 34 additions and 10 deletions
|
|
@ -23,9 +23,8 @@ async function clickhouseQuery(websiteId: string, sessionId: string) {
|
|||
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
session_id as id,
|
||||
website_id as websiteId,
|
||||
select id,
|
||||
websiteId,
|
||||
hostname,
|
||||
browser,
|
||||
os,
|
||||
|
|
@ -37,13 +36,32 @@ async function clickhouseQuery(websiteId: string, sessionId: string) {
|
|||
city,
|
||||
min(min_time) as firstAt,
|
||||
max(max_time) as lastAt,
|
||||
uniq(visit_id) as visits,
|
||||
sumIf(views, event_type = 1) as views,
|
||||
length(groupArrayArray(event_name)) as events
|
||||
from website_event_stats_hourly
|
||||
where website_id = {websiteId:UUID}
|
||||
and session_id = {sessionId:UUID}
|
||||
group by session_id, website_id, hostname, browser, os, device, screen, language, country, subdivision1, city;
|
||||
uniq(visit_id) visits,
|
||||
sum(views) as views,
|
||||
sum(events) as events,
|
||||
sum(max_time-min_time) as totaltime
|
||||
from (select
|
||||
session_id as id,
|
||||
visit_id,
|
||||
website_id as websiteId,
|
||||
hostname,
|
||||
browser,
|
||||
os,
|
||||
device,
|
||||
screen,
|
||||
language,
|
||||
country,
|
||||
subdivision1,
|
||||
city,
|
||||
min(min_time) as min_time,
|
||||
max(max_time) as max_time,
|
||||
sum(views) as views,
|
||||
length(groupArrayArray(event_name)) as events
|
||||
from website_event_stats_hourly
|
||||
where website_id = {websiteId:UUID}
|
||||
and session_id = {sessionId:UUID}
|
||||
group by session_id, visit_id, website_id, hostname, browser, os, device, screen, language, country, subdivision1, city) t
|
||||
group by id, websiteId, hostname, browser, os, device, screen, language, country, subdivision1, city;
|
||||
`,
|
||||
{ websiteId, sessionId },
|
||||
).then(result => result?.[0]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue