mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-06 01:15:42 +01:00
fix realtime queries for stats
This commit is contained in:
parent
174b9e4376
commit
3205b4f0f4
@ -47,6 +47,9 @@ async function clickhouseQuery(
|
|||||||
eventType: EVENT_TYPE.pageView,
|
eventType: EVENT_TYPE.pageView,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const table = unit === 'minute' ? 'website_event' : 'website_event_stats_hourly';
|
||||||
|
const columnQuery = unit === 'minute' ? 'count(*)' : 'sum(views)';
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
@ -55,8 +58,8 @@ async function clickhouseQuery(
|
|||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
${getDateSQL('created_at', unit, timezone)} as t,
|
${getDateSQL('created_at', unit, timezone)} as t,
|
||||||
sum(views) as y
|
${columnQuery} as y
|
||||||
from website_event_stats_hourly website_event
|
from ${table} website_event
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
and event_type = {eventType:UInt32}
|
and event_type = {eventType:UInt32}
|
||||||
|
@ -47,6 +47,9 @@ async function clickhouseQuery(
|
|||||||
eventType: EVENT_TYPE.pageView,
|
eventType: EVENT_TYPE.pageView,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const table = unit === 'minute' ? 'website_event' : 'website_event_stats_hourly';
|
||||||
|
const columnQuery = unit === 'minute' ? 'count(distinct session_id)' : 'uniq(session_id)';
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
@ -55,8 +58,8 @@ async function clickhouseQuery(
|
|||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
${getDateSQL('created_at', unit, timezone)} as t,
|
${getDateSQL('created_at', unit, timezone)} as t,
|
||||||
uniq(session_id) as y
|
${columnQuery} as y
|
||||||
from website_event_stats_hourly website_event
|
from ${table} website_event
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
and event_type = {eventType:UInt32}
|
and event_type = {eventType:UInt32}
|
||||||
|
Loading…
Reference in New Issue
Block a user