Added events to website stats.
parent
0f976be5d8
commit
bb8f611604
|
@ -25,9 +25,11 @@ async function relationalQuery(website_id, start_at, end_at, filters = {}) {
|
|||
filters,
|
||||
params,
|
||||
);
|
||||
const { joinSession: joinEventSession } = parseFilters('event', null, filters, params);
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select * from (
|
||||
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",
|
||||
|
@ -45,6 +47,15 @@ async function relationalQuery(website_id, start_at, end_at, filters = {}) {
|
|||
${sessionQuery}
|
||||
group by 1, 2
|
||||
) t
|
||||
) stats_views
|
||||
cross join (
|
||||
select count(*) events
|
||||
from event
|
||||
${joinEventSession}
|
||||
where event.website_id=$1
|
||||
and event.created_at between $2 and $3
|
||||
${sessionQuery}
|
||||
) stats_events
|
||||
`,
|
||||
params,
|
||||
);
|
||||
|
@ -59,9 +70,11 @@ async function clickhouseQuery(website_id, start_at, end_at, filters = {}) {
|
|||
params,
|
||||
'session_uuid',
|
||||
);
|
||||
const { joinSession: joinEventSession } = parseFilters('event', null, filters, params);
|
||||
|
||||
return rawQueryClickhouse(
|
||||
`
|
||||
select * from (
|
||||
select
|
||||
sum(t.c) as "pageviews",
|
||||
count(distinct t.session_uuid) as "uniques",
|
||||
|
@ -81,6 +94,15 @@ async function clickhouseQuery(website_id, start_at, end_at, filters = {}) {
|
|||
${sessionQuery}
|
||||
group by pageview.session_uuid, time_series
|
||||
) t;
|
||||
) stats_views
|
||||
cross join (
|
||||
select count(*) events
|
||||
from event
|
||||
${joinEventSession}
|
||||
where event.website_id=$1
|
||||
and ${getBetweenDatesClickhouse('event.created_at', start_at, end_at)}
|
||||
${sessionQuery}
|
||||
) stats_events
|
||||
`,
|
||||
params,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue