mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Add table alias to filterQuery. Closed #3869
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
Some checks are pending
Node.js CI / build (postgresql, 18.18, 10) (push) Waiting to run
This commit is contained in:
parent
86d2672c47
commit
3072f02f1b
2 changed files with 14 additions and 7 deletions
|
|
@ -74,15 +74,21 @@ function getSearchSQL(column: string, param: string = 'search'): string {
|
||||||
function mapFilter(column: string, operator: string, name: string, type: string = '') {
|
function mapFilter(column: string, operator: string, name: string, type: string = '') {
|
||||||
const value = `{{${name}${type ? `::${type}` : ''}}}`;
|
const value = `{{${name}${type ? `::${type}` : ''}}}`;
|
||||||
|
|
||||||
|
if (name.startsWith('cohort_')) {
|
||||||
|
name = name.slice('cohort_'.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
const table = SESSION_COLUMNS.includes(name) ? 'session' : 'website_event';
|
||||||
|
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case OPERATORS.equals:
|
case OPERATORS.equals:
|
||||||
return `${column} = ${value}`;
|
return `${table}.${column} = ${value}`;
|
||||||
case OPERATORS.notEquals:
|
case OPERATORS.notEquals:
|
||||||
return `${column} != ${value}`;
|
return `${table}.${column} != ${value}`;
|
||||||
case OPERATORS.contains:
|
case OPERATORS.contains:
|
||||||
return `${column} ilike ${value}`;
|
return `${table}.${column} ilike ${value}`;
|
||||||
case OPERATORS.doesNotContain:
|
case OPERATORS.doesNotContain:
|
||||||
return `${column} not ilike ${value}`;
|
return `${table}.${column} not ilike ${value}`;
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,15 @@ async function relationalQuery(
|
||||||
currency,
|
currency,
|
||||||
});
|
});
|
||||||
|
|
||||||
const joinQuery = filterQuery
|
const joinQuery =
|
||||||
? `join website_event
|
filterQuery || cohortQuery
|
||||||
|
? `join website_event
|
||||||
on website_event.website_id = revenue.website_id
|
on website_event.website_id = revenue.website_id
|
||||||
and website_event.session_id = revenue.session_id
|
and website_event.session_id = revenue.session_id
|
||||||
and website_event.event_id = revenue.event_id
|
and website_event.event_id = revenue.event_id
|
||||||
and website_event.website_id = {{websiteId::uuid}}
|
and website_event.website_id = {{websiteId::uuid}}
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}`
|
and website_event.created_at between {{startDate}} and {{endDate}}`
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
const chart = await rawQuery(
|
const chart = await rawQuery(
|
||||||
`
|
`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue