mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Handle country data for regions and cities.
This commit is contained in:
parent
8c9e473550
commit
684587f945
3 changed files with 13 additions and 15 deletions
|
|
@ -25,13 +25,14 @@ async function relationalQuery(websiteId: string, column: string, filters: Query
|
|||
joinSession: SESSION_COLUMNS.includes(column),
|
||||
},
|
||||
);
|
||||
const includeCountry = column === 'city' || column === 'subdivision1';
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
${column} x,
|
||||
count(*) y
|
||||
${column === 'city' ? ', country' : ''}
|
||||
${includeCountry ? ', country' : ''}
|
||||
from website_event
|
||||
${joinSession}
|
||||
where website_event.website_id = {{websiteId::uuid}}
|
||||
|
|
@ -39,7 +40,7 @@ async function relationalQuery(websiteId: string, column: string, filters: Query
|
|||
and website_event.event_type = {{eventType}}
|
||||
${filterQuery}
|
||||
group by 1
|
||||
${column === 'city' ? ', 3' : ''}
|
||||
${includeCountry ? ', 3' : ''}
|
||||
order by 2 desc
|
||||
limit 100`,
|
||||
params,
|
||||
|
|
@ -52,20 +53,21 @@ async function clickhouseQuery(websiteId: string, column: string, filters: Query
|
|||
...filters,
|
||||
eventType: EVENT_TYPE.pageView,
|
||||
});
|
||||
const includeCountry = column === 'city' || column === 'subdivision1';
|
||||
|
||||
return rawQuery(
|
||||
`
|
||||
select
|
||||
${column} x,
|
||||
count(distinct session_id) y
|
||||
${column === 'city' ? ', country' : ''}
|
||||
${includeCountry ? ', country' : ''}
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and created_at between {startDate:DateTime} and {endDate:DateTime}
|
||||
and event_type = {eventType:UInt32}
|
||||
${filterQuery}
|
||||
group by x
|
||||
${column === 'city' ? ', country' : ''}
|
||||
${includeCountry ? ', country' : ''}
|
||||
order by y desc
|
||||
limit 100
|
||||
`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue