mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Added summary stats query.
This commit is contained in:
parent
18de85a06d
commit
f9a6f5f637
5 changed files with 61 additions and 13 deletions
30
lib/db.js
30
lib/db.js
|
|
@ -179,3 +179,33 @@ export async function getPageviewData(
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
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"
|
||||
`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue