mirror of
https://github.com/umami-software/umami.git
synced 2026-02-20 04:25:39 +01:00
add event data
This commit is contained in:
parent
67394194af
commit
75778fdfc7
22 changed files with 446 additions and 84 deletions
|
|
@ -65,8 +65,7 @@ function getCommaSeparatedStringFormat(data) {
|
|||
}
|
||||
|
||||
function getBetweenDates(field, start_at, end_at) {
|
||||
return `${field} between ${getDateFormat(start_at)}
|
||||
and ${getDateFormat(end_at)}`;
|
||||
return `${field} between ${getDateFormat(start_at)} and ${getDateFormat(end_at)}`;
|
||||
}
|
||||
|
||||
function getJsonField(column, property) {
|
||||
|
|
@ -81,7 +80,7 @@ function getEventDataColumnsQuery(column, columns) {
|
|||
return arr;
|
||||
}
|
||||
|
||||
arr.push(`${filter}(${getJsonField(column, key)})`);
|
||||
arr.push(`${filter}(${getJsonField(column, key)}) as ${key}_${filter}`);
|
||||
|
||||
return arr;
|
||||
}, []);
|
||||
|
|
|
|||
|
|
@ -85,13 +85,13 @@ function getTimestampInterval(field) {
|
|||
}
|
||||
}
|
||||
|
||||
function getJsonField(column, property, value) {
|
||||
function getJsonField(column, property, isNumber) {
|
||||
const db = getDatabaseType(process.env.DATABASE_URL);
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
let accessor = `${column} ->> '${property}'`;
|
||||
|
||||
if (value && typeof value === 'number') {
|
||||
if (isNumber) {
|
||||
accessor = `CAST(${accessor} AS DECIMAL)`;
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +111,9 @@ function getEventDataColumnsQuery(column, columns) {
|
|||
return arr;
|
||||
}
|
||||
|
||||
arr.push(`${filter}(${getJsonField(column, key)})`);
|
||||
const isNumber = ['sum', 'avg', 'min', 'max'].some(a => a === filter);
|
||||
|
||||
arr.push(`${filter}(${getJsonField(column, key, isNumber)}) as "${filter}(${key})"`);
|
||||
|
||||
return arr;
|
||||
}, []);
|
||||
|
|
@ -127,8 +129,10 @@ function getEventDataFilterQuery(column, filters) {
|
|||
return arr;
|
||||
}
|
||||
|
||||
const isNumber = filter && typeof filter === 'number';
|
||||
|
||||
arr.push(
|
||||
`${getJsonField(column, key, filter)} = ${
|
||||
`${getJsonField(column, key, isNumber)} = ${
|
||||
typeof filter === 'string' ? `'${filter}'` : filter
|
||||
}`,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue