mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
Fix metrics.
This commit is contained in:
parent
2172dddd1c
commit
d2687b6580
@ -104,7 +104,7 @@ function getEventDataFilterQuery(
|
||||
return query.join('\n');
|
||||
}
|
||||
|
||||
function getFilterQuery(filters = {}, params = {}) {
|
||||
function getFilterQuery(filters = {}, params = {}, field: string) {
|
||||
const query = Object.keys(filters).reduce((arr, key) => {
|
||||
const filter = filters[key];
|
||||
|
||||
@ -112,6 +112,10 @@ function getFilterQuery(filters = {}, params = {}) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (key === field) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case 'url':
|
||||
arr.push(`and url_path = {${key}:String}`);
|
||||
@ -157,7 +161,7 @@ function getFilterQuery(filters = {}, params = {}) {
|
||||
return query.join('\n');
|
||||
}
|
||||
|
||||
function parseFilters(filters: any = {}, params: any = {}) {
|
||||
function parseFilters(filters: any = {}, params: any = {}, field?: string) {
|
||||
const {
|
||||
domain,
|
||||
url,
|
||||
@ -184,7 +188,7 @@ function parseFilters(filters: any = {}, params: any = {}) {
|
||||
sessionFilters,
|
||||
eventFilters,
|
||||
event: { eventName },
|
||||
filterQuery: getFilterQuery(filters, params),
|
||||
filterQuery: getFilterQuery(filters, params, field),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ function getEventDataFilterQuery(
|
||||
return query.join('\n');
|
||||
}
|
||||
|
||||
function getFilterQuery(filters = {}, params = []): string {
|
||||
function getFilterQuery(filters = {}, params = [], field: string): string {
|
||||
const query = Object.keys(filters).reduce((arr, key) => {
|
||||
const filter = filters[key];
|
||||
|
||||
@ -114,6 +114,10 @@ function getFilterQuery(filters = {}, params = []): string {
|
||||
return arr;
|
||||
}
|
||||
|
||||
if (key === field) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case 'url':
|
||||
arr.push(`and url_path=$${params.length + 1}`);
|
||||
@ -162,6 +166,7 @@ function getFilterQuery(filters = {}, params = []): string {
|
||||
function parseFilters(
|
||||
filters: { [key: string]: any } = {},
|
||||
params = [],
|
||||
field?: string,
|
||||
sessionKey = 'session_id',
|
||||
) {
|
||||
const {
|
||||
@ -194,7 +199,7 @@ function parseFilters(
|
||||
os || browser || device || country || subdivision1 || subdivision2 || city
|
||||
? `inner join session on website_event.${sessionKey} = session.${sessionKey}`
|
||||
: '',
|
||||
filterQuery: getFilterQuery(filters, params),
|
||||
filterQuery: getFilterQuery(filters, params, field),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ async function clickhouseQuery(
|
||||
const website = await cache.fetchWebsite(websiteId);
|
||||
const resetDate = website?.resetAt || website?.createdAt;
|
||||
const params = { websiteId };
|
||||
const { filterQuery } = parseFilters(filters, params);
|
||||
const { filterQuery } = parseFilters(filters, params, field);
|
||||
|
||||
return rawQuery(
|
||||
`select ${field} x, count(distinct session_id) y
|
||||
|
Loading…
Reference in New Issue
Block a user