mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
Updated realtime data fetch.
This commit is contained in:
parent
04e0b33622
commit
e35c11c3d6
9 changed files with 126 additions and 87 deletions
|
|
@ -40,8 +40,8 @@ async function clickhouseQuery(
|
|||
websiteId: string,
|
||||
filters: QueryFilters,
|
||||
): Promise<{ x: string; y: number }[]> {
|
||||
const { timezone = 'UTC', unit = 'day' } = filters;
|
||||
const { parseFilters, rawQuery, getDateStringSQL, getDateSQL } = clickhouse;
|
||||
const { unit = 'day' } = filters;
|
||||
const { parseFilters, rawQuery } = clickhouse;
|
||||
const { filterQuery, params } = await parseFilters(websiteId, {
|
||||
...filters,
|
||||
eventType: EVENT_TYPE.pageView,
|
||||
|
|
@ -52,11 +52,11 @@ async function clickhouseQuery(
|
|||
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item)) || unit === 'minute') {
|
||||
sql = `
|
||||
select
|
||||
${getDateStringSQL('g.t', unit)} as x,
|
||||
g.t as x,
|
||||
g.y as y
|
||||
from (
|
||||
select
|
||||
${getDateSQL('created_at', unit, timezone)} as t,
|
||||
select
|
||||
date_trunc('${unit}', created_at) as t,
|
||||
count(distinct session_id) as y
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
|
|
@ -70,11 +70,11 @@ async function clickhouseQuery(
|
|||
} else {
|
||||
sql = `
|
||||
select
|
||||
${getDateStringSQL('g.t', unit)} as x,
|
||||
g.t as x,
|
||||
g.y as y
|
||||
from (
|
||||
select
|
||||
${getDateSQL('created_at', unit, timezone)} as t,
|
||||
select
|
||||
date_trunc('${unit}', created_at) as t,
|
||||
uniq(session_id) as y
|
||||
from website_event_stats_hourly website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue