mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
match cloud stats in self hosted
This commit is contained in:
parent
8a4623eb7b
commit
76a5ac8e46
3 changed files with 20 additions and 16 deletions
|
|
@ -12,7 +12,8 @@ export async function getWebsiteStats(...args: [websiteId: string, filters: Quer
|
|||
}
|
||||
|
||||
async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||
const { getDateQuery, getTimestampIntervalQuery, parseFilters, rawQuery } = prisma;
|
||||
const { getDateQuery, getAddIntervalQuery, getTimestampDiffQuery, parseFilters, rawQuery } =
|
||||
prisma;
|
||||
const { filterQuery, joinSession, params } = await parseFilters(websiteId, {
|
||||
...filters,
|
||||
eventType: EVENT_TYPE.pageView,
|
||||
|
|
@ -24,13 +25,16 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
|||
sum(t.c) as "pageviews",
|
||||
count(distinct t.session_id) as "uniques",
|
||||
sum(case when t.c = 1 then 1 else 0 end) as "bounces",
|
||||
sum(t.time) as "totaltime"
|
||||
sum(case when t.max_time < ${getAddIntervalQuery('t.min_time', '1 hour')}
|
||||
then ${getTimestampDiffQuery('t.min_time', 't.max_time')}
|
||||
else 0 end) as "totaltime"
|
||||
from (
|
||||
select
|
||||
website_event.session_id,
|
||||
${getDateQuery('website_event.created_at', 'hour')},
|
||||
count(*) as c,
|
||||
${getTimestampIntervalQuery('website_event.created_at')} as "time"
|
||||
${getDateQuery('website_event.created_at', 'day')},
|
||||
count(*) as "c",
|
||||
min(website_event.created_at) as "min_time",
|
||||
max(website_event.created_at) as "max_time"
|
||||
from website_event
|
||||
join website
|
||||
on website_event.website_id = website.website_id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue