mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 16:45:35 +01:00
move queries
This commit is contained in:
parent
910f165103
commit
8aec6d7406
53 changed files with 920 additions and 485 deletions
29
queries/analytics/stats/getWebsiteStats.js
Normal file
29
queries/analytics/stats/getWebsiteStats.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { parseFilters, rawQuery, getDateQuery, getTimestampInterval } from 'queries';
|
||||
|
||||
export function getWebsiteStats(website_id, start_at, end_at, filters = {}) {
|
||||
const params = [website_id, start_at, end_at];
|
||||
const { pageviewQuery, sessionQuery, joinSession } = parseFilters('pageview', filters, params);
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select 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"
|
||||
from (
|
||||
select pageview.session_id,
|
||||
${getDateQuery('pageview.created_at', 'hour')},
|
||||
count(*) c,
|
||||
${getTimestampInterval('pageview.created_at')} as "time"
|
||||
from pageview
|
||||
${joinSession}
|
||||
where pageview.website_id=$1
|
||||
and pageview.created_at between $2 and $3
|
||||
${pageviewQuery}
|
||||
${sessionQuery}
|
||||
group by 1, 2
|
||||
) t
|
||||
`,
|
||||
params,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue