mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-01 12:29:35 +01:00
fix insights column name bug
This commit is contained in:
parent
8955c3d30d
commit
3c259109aa
@ -43,7 +43,7 @@ async function relationalQuery(
|
|||||||
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",
|
||||||
sum(${getTimestampDiffQuery('t.min_time', 't.max_time')}) as "totaltime",
|
sum(${getTimestampDiffQuery('t.min_time', 't.max_time')}) as "totaltime",
|
||||||
${parseFields(fields)}
|
${parseFieldsByName(fields)}
|
||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
${parseFields(fields)},
|
${parseFields(fields)},
|
||||||
@ -58,10 +58,10 @@ async function relationalQuery(
|
|||||||
and website_event.created_at between {{startDate}} and {{endDate}}
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
and event_type = {{eventType}}
|
and event_type = {{eventType}}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by ${parseFields(fields)},
|
group by ${parseFieldsByName(fields)},
|
||||||
website_event.session_id, website_event.visit_id
|
website_event.session_id, website_event.visit_id
|
||||||
) as t
|
) as t
|
||||||
group by ${parseFields(fields)}
|
group by ${parseFieldsByName(fields)}
|
||||||
order by 1 desc, 2 desc
|
order by 1 desc, 2 desc
|
||||||
limit 500
|
limit 500
|
||||||
`,
|
`,
|
||||||
@ -93,7 +93,7 @@ async function clickhouseQuery(
|
|||||||
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",
|
||||||
sum(max_time-min_time) as "totaltime",
|
sum(max_time-min_time) as "totaltime",
|
||||||
${parseFields(fields)}
|
${parseFieldsByName(fields)}
|
||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
${parseFields(fields)},
|
${parseFields(fields)},
|
||||||
@ -107,10 +107,10 @@ async function clickhouseQuery(
|
|||||||
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}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by ${parseFields(fields)},
|
group by ${parseFieldsByName(fields)},
|
||||||
session_id, visit_id
|
session_id, visit_id
|
||||||
) as t
|
) as t
|
||||||
group by ${parseFields(fields)}
|
group by ${parseFieldsByName(fields)}
|
||||||
order by 1 desc, 2 desc
|
order by 1 desc, 2 desc
|
||||||
limit 500
|
limit 500
|
||||||
`,
|
`,
|
||||||
@ -130,5 +130,9 @@ async function clickhouseQuery(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseFields(fields: { name: any }[]) {
|
function parseFields(fields: { name: any }[]) {
|
||||||
return `${fields.map(({ name }) => FILTER_COLUMNS[name]).join(',')}`;
|
return fields.map(({ name }) => `${FILTER_COLUMNS[name]} as "${name}"`).join(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseFieldsByName(fields: { name: any }[]) {
|
||||||
|
return `${fields.map(({ name }) => name).join(',')}`;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user