mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 06:07:17 +01:00
update UTM report to use new UTM columns
This commit is contained in:
parent
822ddee9ae
commit
6829d96862
4 changed files with 40 additions and 34 deletions
|
|
@ -4,6 +4,7 @@ import prisma from '@/lib/prisma';
|
|||
import { QueryFilters } from '@/lib/types';
|
||||
|
||||
export interface UTMParameters {
|
||||
column: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
}
|
||||
|
|
@ -22,10 +23,10 @@ async function relationalQuery(
|
|||
parameters: UTMParameters,
|
||||
filters: QueryFilters,
|
||||
) {
|
||||
const { startDate, endDate } = parameters;
|
||||
const { column, startDate, endDate } = parameters;
|
||||
const { parseFilters, rawQuery } = prisma;
|
||||
|
||||
const { filterQuery, queryParams } = parseFilters({
|
||||
const { filterQuery, cohortQuery, queryParams } = parseFilters({
|
||||
...filters,
|
||||
websiteId,
|
||||
startDate,
|
||||
|
|
@ -34,14 +35,16 @@ async function relationalQuery(
|
|||
|
||||
return rawQuery(
|
||||
`
|
||||
select url_query, count(*) as "num"
|
||||
select ${column} utm, count(*) as views
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
where website_id = {{websiteId::uuid}}
|
||||
and created_at between {{startDate}} and {{endDate}}
|
||||
and coalesce(url_query, '') != ''
|
||||
and coalesce(${column}, '') != ''
|
||||
and event_type = 1
|
||||
${filterQuery}
|
||||
group by 1
|
||||
order by 2 desc
|
||||
`,
|
||||
queryParams,
|
||||
);
|
||||
|
|
@ -52,9 +55,9 @@ async function clickhouseQuery(
|
|||
parameters: UTMParameters,
|
||||
filters: QueryFilters,
|
||||
) {
|
||||
const { startDate, endDate } = parameters;
|
||||
const { column, startDate, endDate } = parameters;
|
||||
const { parseFilters, rawQuery } = clickhouse;
|
||||
const { filterQuery, queryParams } = parseFilters({
|
||||
const { filterQuery, cohortQuery, queryParams } = parseFilters({
|
||||
...filters,
|
||||
websiteId,
|
||||
startDate,
|
||||
|
|
@ -63,14 +66,16 @@ async function clickhouseQuery(
|
|||
|
||||
return rawQuery(
|
||||
`
|
||||
select url_query, count(*) as "num"
|
||||
select ${column} utm, count(*) as views
|
||||
from website_event
|
||||
${cohortQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and url_query != ''
|
||||
and ${column} != ''
|
||||
and event_type = 1
|
||||
${filterQuery}
|
||||
group by 1
|
||||
order by 2 desc
|
||||
`,
|
||||
queryParams,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue