mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 23:57:12 +01:00
Updated summary query. Added visit time.
This commit is contained in:
parent
da2d383b71
commit
efdbd1c632
4 changed files with 69 additions and 24 deletions
37
lib/db.js
37
lib/db.js
|
|
@ -184,28 +184,21 @@ export async function getSummary(website_id, start_at, end_at) {
|
|||
return runQuery(
|
||||
prisma.queryRaw(
|
||||
`
|
||||
select
|
||||
(select count(*)
|
||||
from pageview
|
||||
where website_id=${website_id}
|
||||
and created_at between '${start_at}' and '${end_at}'
|
||||
) as "pageviews",
|
||||
(select
|
||||
count(distinct session_id)
|
||||
from pageview
|
||||
where website_id=${website_id}
|
||||
and created_at between '${start_at}' and '${end_at}'
|
||||
) as "uniques",
|
||||
(select sum(t.c) from
|
||||
(select count(*) c
|
||||
from pageview
|
||||
where website_id=${website_id}
|
||||
and created_at between '${start_at}' and '${end_at}'
|
||||
group by session_id
|
||||
having count(*) = 1
|
||||
) t
|
||||
) as "bounces"
|
||||
`,
|
||||
select sum(t.c) as "pageviews",
|
||||
count(distinct t.session_id) as "uniques",
|
||||
sum(case when t.c = 1 then t.c else 0 end) as "bounces",
|
||||
sum(t.time) as "totaltime"
|
||||
from (
|
||||
select session_id,
|
||||
date_trunc('hour', created_at),
|
||||
count(*) c,
|
||||
floor(extract(epoch from max(created_at) - min(created_at))) as "time"
|
||||
from pageview
|
||||
where website_id=${website_id}
|
||||
and created_at between '${start_at}' and '${end_at}'
|
||||
group by 1, 2
|
||||
) t;
|
||||
`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue