mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
Updates to insights, event data, telemetry.
This commit is contained in:
parent
39562d4a64
commit
e4bd314bd6
44 changed files with 413 additions and 278 deletions
|
|
@ -62,10 +62,6 @@ function getDateFormat(date) {
|
|||
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
|
||||
}
|
||||
|
||||
function getBetweenDates(field, startAt, endAt) {
|
||||
return `${field} between ${getDateFormat(startAt)} and ${getDateFormat(endAt)}`;
|
||||
}
|
||||
|
||||
function getEventDataFilterQuery(
|
||||
filters: {
|
||||
eventKey?: string;
|
||||
|
|
@ -150,7 +146,22 @@ function parseFilters(filters: WebsiteMetricFilter = {}, params: any = {}) {
|
|||
};
|
||||
}
|
||||
|
||||
async function rawQuery<T>(query, params = {}): Promise<T> {
|
||||
function formatField(field, type, value) {
|
||||
switch (type) {
|
||||
case 'date':
|
||||
return getDateFormat(value);
|
||||
default:
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
async function rawQuery<T>(sql, params = {}): Promise<T> {
|
||||
const query = sql.replaceAll(/\{\{\w+:\w+}}/g, token => {
|
||||
const [, field, type] = token.match(/\{\{(\w+):(\w+)}}/);
|
||||
|
||||
return formatField(field, type, params[field]);
|
||||
});
|
||||
|
||||
if (process.env.LOG_QUERY) {
|
||||
log('QUERY:\n', query);
|
||||
log('PARAMETERS:\n', params);
|
||||
|
|
@ -189,7 +200,6 @@ export default {
|
|||
getDateStringQuery,
|
||||
getDateQuery,
|
||||
getDateFormat,
|
||||
getBetweenDates,
|
||||
getFilterQuery,
|
||||
getFunnelQuery,
|
||||
getEventDataFilterQuery,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue