mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Removed output parsing for clickhouse.
This commit is contained in:
parent
592708eafd
commit
7a0575e33a
9 changed files with 20 additions and 51 deletions
|
|
@ -194,5 +194,5 @@ export async function POST(request: Request) {
|
|||
|
||||
const token = createToken({ websiteId, sessionId, visitId, iat }, secret());
|
||||
|
||||
return json({ cache: token, websiteId, sessionId, visitId, iat });
|
||||
return json({ cache: token });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ function getFilterQuery(filters: QueryFilters = {}, options: QueryOptions = {})
|
|||
arr.push(`and ${mapFilter(column, operator, name)}`);
|
||||
|
||||
if (name === 'referrer') {
|
||||
arr.push('and referrer_domain != {websiteDomain:String}');
|
||||
arr.push('and referrer_domain != hostname');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ async function pagedQuery(
|
|||
) {
|
||||
const { page = 1, pageSize, orderBy, sortDescending = false } = pageParams;
|
||||
const size = +pageSize || DEFAULT_PAGE_SIZE;
|
||||
const offset = +size * (page - 1);
|
||||
const offset = +size * (+page - 1);
|
||||
const direction = sortDescending ? 'desc' : 'asc';
|
||||
|
||||
const statements = [
|
||||
|
|
|
|||
|
|
@ -86,9 +86,5 @@ async function clickhouseQuery(
|
|||
`;
|
||||
}
|
||||
|
||||
return rawQuery(sql, params).then(a => {
|
||||
return Object.values(a).map(a => {
|
||||
return { x: a.x, t: a.t, y: Number(a.y) };
|
||||
});
|
||||
});
|
||||
return rawQuery(sql, params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,5 @@ function clickhouseQuery(
|
|||
startDate,
|
||||
endDate,
|
||||
},
|
||||
).then(a => {
|
||||
return Object.values(a).map(a => {
|
||||
return { websiteId: a.websiteId, count: Number(a.count) };
|
||||
});
|
||||
});
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export function getWebsiteEvents(
|
|||
|
||||
async function relationalQuery(websiteId: string, filters: QueryFilters, pageParams?: PageParams) {
|
||||
const { pagedRawQuery, parseFilters } = prisma;
|
||||
const { query } = pageParams;
|
||||
const { search } = pageParams;
|
||||
const { filterQuery, params } = await parseFilters(websiteId, {
|
||||
...filters,
|
||||
});
|
||||
|
|
@ -43,16 +43,16 @@ async function relationalQuery(websiteId: string, filters: QueryFilters, pagePar
|
|||
and created_at between {{startDate}} and {{endDate}}
|
||||
${filterQuery}
|
||||
${
|
||||
query
|
||||
? `and ((event_name ${like} {{query}} and event_type = 2)
|
||||
or (url_path ${like} {{query}} and event_type = 1))`
|
||||
search
|
||||
? `and ((event_name ${like} {{search}} and event_type = 2)
|
||||
or (url_path ${like} {{search}} and event_type = 1))`
|
||||
: ''
|
||||
}
|
||||
order by created_at desc
|
||||
limit 1000)
|
||||
select * from events
|
||||
`,
|
||||
{ ...params, query: `%${query}%` },
|
||||
{ ...params, query: `%${search}%` },
|
||||
pageParams,
|
||||
);
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters, pagePar
|
|||
async function clickhouseQuery(websiteId: string, filters: QueryFilters, pageParams?: PageParams) {
|
||||
const { pagedQuery, parseFilters } = clickhouse;
|
||||
const { params, dateQuery, filterQuery } = await parseFilters(websiteId, filters);
|
||||
const { query } = pageParams;
|
||||
const { search } = pageParams;
|
||||
|
||||
return pagedQuery(
|
||||
`
|
||||
|
|
@ -83,16 +83,16 @@ async function clickhouseQuery(websiteId: string, filters: QueryFilters, pagePar
|
|||
${dateQuery}
|
||||
${filterQuery}
|
||||
${
|
||||
query
|
||||
? `and ((positionCaseInsensitive(event_name, {query:String}) > 0 and event_type = 2)
|
||||
or (positionCaseInsensitive(url_path, {query:String}) > 0 and event_type = 1))`
|
||||
search
|
||||
? `and ((positionCaseInsensitive(event_name, {search:String}) > 0 and event_type = 2)
|
||||
or (positionCaseInsensitive(url_path, {search:String}) > 0 and event_type = 1))`
|
||||
: ''
|
||||
}
|
||||
order by created_at desc
|
||||
limit 1000)
|
||||
select * from events
|
||||
`,
|
||||
{ ...params, query },
|
||||
{ ...params, search },
|
||||
pageParams,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,5 @@ async function clickhouseQuery(
|
|||
order by visitors desc
|
||||
`;
|
||||
|
||||
return rawQuery(sql, params).then(a => {
|
||||
return Object.values(a).map(a => {
|
||||
return { ...a, visitors: Number(a.visitors) };
|
||||
});
|
||||
});
|
||||
return rawQuery(sql, params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ async function relationalQuery(
|
|||
let entryExitQuery = '';
|
||||
let excludeDomain = '';
|
||||
if (column === 'referrer_domain') {
|
||||
excludeDomain = `and website_event.referrer_domain != {{websiteDomain}}
|
||||
excludeDomain = `and website_event.referrer_domain != website_event.hostname
|
||||
and website_event.referrer_domain is not null`;
|
||||
}
|
||||
|
||||
|
|
@ -175,9 +175,5 @@ async function clickhouseQuery(
|
|||
`;
|
||||
}
|
||||
|
||||
return rawQuery(sql, params).then((result: any) => {
|
||||
return Object.values(result).map((a: any) => {
|
||||
return { x: a.x, y: Number(a.y) };
|
||||
});
|
||||
});
|
||||
return rawQuery(sql, params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,18 +115,7 @@ async function clickhouseQuery(
|
|||
limit 500
|
||||
`,
|
||||
params,
|
||||
).then(a => {
|
||||
return Object.values(a).map(a => {
|
||||
return {
|
||||
...a,
|
||||
views: Number(a.views),
|
||||
visitors: Number(a.visitors),
|
||||
visits: Number(a.visits),
|
||||
bounces: Number(a.bounces),
|
||||
totaltime: Number(a.totaltime),
|
||||
};
|
||||
});
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
function parseFields(fields: { name: any }[]) {
|
||||
|
|
|
|||
|
|
@ -115,9 +115,5 @@ async function clickhouseQuery(
|
|||
`;
|
||||
}
|
||||
|
||||
return rawQuery(sql, params).then(a => {
|
||||
return Object.values(a).map(a => {
|
||||
return { x: a.x, y: Number(a.y), country: a.country };
|
||||
});
|
||||
});
|
||||
return rawQuery(sql, params);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue