mirror of
https://github.com/umami-software/umami.git
synced 2026-02-17 11: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
|
|
@ -34,9 +34,9 @@ async function relationalQuery(website_id, { startDate, endDate, column, table,
|
|||
);
|
||||
}
|
||||
|
||||
async function clickhouseQuery(website_id, { startDate, endDate, column, filters = {} }) {
|
||||
async function clickhouseQuery(website_uuid, { startDate, endDate, column, filters = {} }) {
|
||||
const { rawQuery, parseFilters, getBetweenDates } = clickhouse;
|
||||
const params = [website_id];
|
||||
const params = [website_uuid];
|
||||
const { pageviewQuery, sessionQuery, eventQuery } = parseFilters(column, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ async function relationalQuery(
|
|||
}
|
||||
|
||||
async function clickhouseQuery(
|
||||
website_id,
|
||||
website_uuid,
|
||||
{ start_at, end_at, timezone = 'UTC', unit = 'day', count = '*', filters = {} },
|
||||
) {
|
||||
const { parseFilters, rawQuery, getDateStringQuery, getDateQuery, getBetweenDates } = clickhouse;
|
||||
const params = [website_id];
|
||||
const params = [website_uuid];
|
||||
const { pageviewQuery, sessionQuery } = parseFilters(null, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
|
|
@ -59,7 +59,7 @@ async function clickhouseQuery(
|
|||
from
|
||||
(select
|
||||
${getDateQuery('created_at', unit, timezone)} t,
|
||||
count(${count !== '*' ? 'distinct session_uuid' : count}) y
|
||||
count(${count !== '*' ? 'distinct session_id' : count}) y
|
||||
from event
|
||||
where event_name = ''
|
||||
and website_id= $1
|
||||
|
|
|
|||
|
|
@ -25,15 +25,21 @@ async function relationalQuery(websites, start_at) {
|
|||
}
|
||||
|
||||
async function clickhouseQuery(websites, start_at) {
|
||||
const { getCommaSeparatedStringFormat } = clickhouse;
|
||||
|
||||
return clickhouse.rawQuery(
|
||||
`select
|
||||
website_id,
|
||||
session_uuid,
|
||||
session_id,
|
||||
created_at,
|
||||
url
|
||||
from event
|
||||
where event_name = ''
|
||||
and ${websites && websites.length > 0 ? `website_id in (${websites.join(',')})` : '0 = 0'}
|
||||
and ${
|
||||
websites && websites.length > 0
|
||||
? `website_id in (${getCommaSeparatedStringFormat(websites, websites.website_uuid)})`
|
||||
: '0 = 0'
|
||||
}
|
||||
and created_at >= ${clickhouse.getDateFormat(start_at)}`,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ async function relationalQuery(website_id, { session: { session_id }, url, refer
|
|||
}
|
||||
|
||||
async function clickhouseQuery(
|
||||
website_id,
|
||||
website_uuid,
|
||||
{ session: { country, ...sessionArgs }, url, referrer },
|
||||
) {
|
||||
const { getDateFormat, sendMessage } = kafka;
|
||||
const params = {
|
||||
website_id: website_id,
|
||||
website_id: website_uuid,
|
||||
created_at: getDateFormat(new Date()),
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
referrer: referrer?.substring(0, URL_LENGTH),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue