mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
implement pageviews, events, and channels queries
This commit is contained in:
parent
c1cad16cb9
commit
0a0c1f27c6
24 changed files with 521 additions and 86 deletions
|
|
@ -25,7 +25,7 @@ async function relationalQuery(
|
|||
filters: QueryFilters,
|
||||
) {
|
||||
const { type, limit = 500, offset = 0 } = parameters;
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
let column = FILTER_COLUMNS[type] || type;
|
||||
const { parseFilters, rawQuery } = prisma;
|
||||
const { filterQuery, joinSessionQuery, cohortQuery, queryParams } = parseFilters(
|
||||
{
|
||||
|
|
@ -39,6 +39,10 @@ async function relationalQuery(
|
|||
);
|
||||
const includeCountry = column === 'city' || column === 'region';
|
||||
|
||||
if (type === 'language') {
|
||||
column = `lower(left(${type}, 2))`;
|
||||
}
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
|
|
@ -68,7 +72,7 @@ async function clickhouseQuery(
|
|||
filters: QueryFilters,
|
||||
): Promise<{ x: string; y: number }[]> {
|
||||
const { type, limit = 500, offset = 0 } = parameters;
|
||||
const column = FILTER_COLUMNS[type] || type;
|
||||
let column = FILTER_COLUMNS[type] || type;
|
||||
const { parseFilters, rawQuery } = clickhouse;
|
||||
const { filterQuery, cohortQuery, queryParams } = parseFilters({
|
||||
...filters,
|
||||
|
|
@ -77,6 +81,10 @@ async function clickhouseQuery(
|
|||
});
|
||||
const includeCountry = column === 'city' || column === 'region';
|
||||
|
||||
if (type === 'language') {
|
||||
column = `lower(left(${type}, 2))`;
|
||||
}
|
||||
|
||||
let sql = '';
|
||||
|
||||
if (EVENT_COLUMNS.some(item => Object.keys(filters).includes(item))) {
|
||||
|
|
@ -89,7 +97,6 @@ async function clickhouseQuery(
|
|||
${cohortQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = {eventType:UInt32}
|
||||
${filterQuery}
|
||||
group by x
|
||||
${includeCountry ? ', country' : ''}
|
||||
|
|
@ -107,7 +114,6 @@ async function clickhouseQuery(
|
|||
${cohortQuery}
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
and event_type = {eventType:UInt32}
|
||||
${filterQuery}
|
||||
group by x
|
||||
${includeCountry ? ', country' : ''}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue