Fixed column name for pageviews.

This commit is contained in:
Mike Cao 2024-03-27 17:07:03 -07:00
parent 740a9408c0
commit cfa568f15c

View File

@ -30,7 +30,7 @@ async function relationalQuery(
return rawQuery( return rawQuery(
` `
select select
sum(t.c) as "views", sum(t.c) as "pageviews",
count(distinct t.session_id) as "visitors", count(distinct t.session_id) as "visitors",
count(distinct t.visit_id) as "visits", count(distinct t.visit_id) as "visits",
sum(case when t.c = 1 then 1 else 0 end) as "bounces", sum(case when t.c = 1 then 1 else 0 end) as "bounces",
@ -72,7 +72,7 @@ async function clickhouseQuery(
return rawQuery( return rawQuery(
` `
select select
sum(t.c) as "views", sum(t.c) as "pageviews",
count(distinct t.session_id) as "visitors", count(distinct t.session_id) as "visitors",
count(distinct t.visit_id) as "visits", count(distinct t.visit_id) as "visits",
sum(if(t.c = 1, 1, 0)) as "bounces", sum(if(t.c = 1, 1, 0)) as "bounces",
@ -93,14 +93,14 @@ async function clickhouseQuery(
) as t; ) as t;
`, `,
params, params,
).then(a => { ).then(result => {
return Object.values(a).map(a => { return Object.values(result).map(n => {
return { return {
pageviews: Number(a.views), pageviews: Number(n.pageviews),
visitors: Number(a.visitors), visitors: Number(n.visitors),
visits: Number(a.visits), visits: Number(n.visits),
bounces: Number(a.bounces), bounces: Number(n.bounces),
totaltime: Number(a.totaltime), totaltime: Number(n.totaltime),
}; };
}); });
}); });