mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Refactor filter handling for queries.
This commit is contained in:
parent
5b300f1ff5
commit
ee6c68d27c
107 changed files with 731 additions and 835 deletions
|
|
@ -244,7 +244,7 @@ async function clickhouseQuery(
|
|||
const { rawQuery, parseFilters } = clickhouse;
|
||||
const eventType = type === 'page' ? EVENT_TYPE.pageView : EVENT_TYPE.customEvent;
|
||||
const column = type === 'page' ? 'url_path' : 'event_name';
|
||||
const { filterQuery, filterParams } = await parseFilters(websiteId, criteria);
|
||||
const { filterQuery, queryParams } = await parseFilters(criteria);
|
||||
|
||||
function getUTMQuery(utmColumn: string) {
|
||||
return `
|
||||
|
|
@ -345,7 +345,7 @@ async function clickhouseQuery(
|
|||
order by 2 desc
|
||||
limit 20
|
||||
`,
|
||||
{ ...filterParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
{ ...queryParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
);
|
||||
|
||||
const paidAdsres = await rawQuery<
|
||||
|
|
@ -376,7 +376,7 @@ async function clickhouseQuery(
|
|||
order by 2 desc
|
||||
limit 20
|
||||
`,
|
||||
{ ...filterParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
{ ...queryParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
);
|
||||
|
||||
const sourceRes = await rawQuery<
|
||||
|
|
@ -390,7 +390,7 @@ async function clickhouseQuery(
|
|||
${getModelQuery(model)}
|
||||
${getUTMQuery('utm_source')}
|
||||
`,
|
||||
{ ...filterParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
{ ...queryParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
);
|
||||
|
||||
const mediumRes = await rawQuery<
|
||||
|
|
@ -404,7 +404,7 @@ async function clickhouseQuery(
|
|||
${getModelQuery(model)}
|
||||
${getUTMQuery('utm_medium')}
|
||||
`,
|
||||
{ ...filterParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
{ ...queryParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
);
|
||||
|
||||
const campaignRes = await rawQuery<
|
||||
|
|
@ -418,7 +418,7 @@ async function clickhouseQuery(
|
|||
${getModelQuery(model)}
|
||||
${getUTMQuery('utm_campaign')}
|
||||
`,
|
||||
{ ...filterParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
{ ...queryParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
);
|
||||
|
||||
const contentRes = await rawQuery<
|
||||
|
|
@ -432,7 +432,7 @@ async function clickhouseQuery(
|
|||
${getModelQuery(model)}
|
||||
${getUTMQuery('utm_content')}
|
||||
`,
|
||||
{ ...filterParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
{ ...queryParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
);
|
||||
|
||||
const termRes = await rawQuery<
|
||||
|
|
@ -446,7 +446,7 @@ async function clickhouseQuery(
|
|||
${getModelQuery(model)}
|
||||
${getUTMQuery('utm_term')}
|
||||
`,
|
||||
{ ...filterParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
{ ...queryParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
);
|
||||
|
||||
const totalRes = await rawQuery<{ pageviews: number; visitors: number; visits: number }>(
|
||||
|
|
@ -462,7 +462,7 @@ async function clickhouseQuery(
|
|||
and event_type = {eventType:UInt32}
|
||||
${filterQuery}
|
||||
`,
|
||||
{ ...filterParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
{ ...queryParams, websiteId, startDate, endDate, conversionStep: step, eventType, currency },
|
||||
).then(result => result?.[0]);
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue