mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 10:05:36 +01:00
update api to new CH columns
This commit is contained in:
parent
36edbe2f4c
commit
96add409b6
19 changed files with 74 additions and 48 deletions
|
|
@ -23,12 +23,12 @@ async function relationalQuery(website_id) {
|
|||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(website_id) {
|
||||
async function clickhouseQuery(website_uuid) {
|
||||
const { rawQuery, getDateFormat } = clickhouse;
|
||||
const params = [website_id];
|
||||
const params = [website_uuid];
|
||||
|
||||
return rawQuery(
|
||||
`select count(distinct session_uuid) x
|
||||
`select count(distinct session_id) x
|
||||
from event
|
||||
where website_id = $1
|
||||
and created_at >= ${getDateFormat(subMinutes(new Date(), 5))}`,
|
||||
|
|
|
|||
|
|
@ -41,19 +41,19 @@ async function relationalQuery(website_id, { start_at, end_at, filters = {} }) {
|
|||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(website_id, { start_at, end_at, filters = {} }) {
|
||||
async function clickhouseQuery(website_uuid, { start_at, end_at, filters = {} }) {
|
||||
const { rawQuery, getDateQuery, getBetweenDates, parseFilters } = clickhouse;
|
||||
const params = [website_id];
|
||||
const params = [website_uuid];
|
||||
const { pageviewQuery, sessionQuery } = parseFilters(null, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
`select
|
||||
sum(t.c) as "pageviews",
|
||||
count(distinct t.session_uuid) as "uniques",
|
||||
count(distinct t.session_id) as "uniques",
|
||||
sum(if(t.c = 1, 1, 0)) as "bounces",
|
||||
sum(if(max_time < min_time + interval 1 hour, max_time-min_time, 0)) as "totaltime"
|
||||
from (
|
||||
select session_uuid,
|
||||
select session_id,
|
||||
${getDateQuery('created_at', 'day')} time_series,
|
||||
count(*) c,
|
||||
min(created_at) min_time,
|
||||
|
|
@ -64,7 +64,7 @@ async function clickhouseQuery(website_id, { start_at, end_at, filters = {} }) {
|
|||
and ${getBetweenDates('created_at', start_at, end_at)}
|
||||
${pageviewQuery}
|
||||
${sessionQuery}
|
||||
group by session_uuid, time_series
|
||||
group by session_id, time_series
|
||||
) t;`,
|
||||
params,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue