mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # queries/analytics/reports/getRetention.ts
This commit is contained in:
commit
d7bf793050
18 changed files with 153 additions and 104 deletions
|
|
@ -5,6 +5,7 @@ import { FILTER_COLUMNS, SESSION_COLUMNS, OPERATORS } from './constants';
|
|||
import { loadWebsite } from './load';
|
||||
import { maxDate } from './date';
|
||||
import { QueryFilters, QueryOptions, SearchFilter } from './types';
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
const MYSQL_DATE_FORMATS = {
|
||||
minute: '%Y-%m-%d %H:%i:00',
|
||||
|
|
@ -34,6 +35,30 @@ function getAddMinutesQuery(field: string, minutes: number): string {
|
|||
}
|
||||
}
|
||||
|
||||
function getDayDiffQuery(field1: string, field2: string): string {
|
||||
const db = getDatabaseType(process.env.DATABASE_URL);
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
return `${field1}::date - ${field2}::date`;
|
||||
}
|
||||
|
||||
if (db === MYSQL) {
|
||||
return `DATEDIFF(${field1}, ${field2})`;
|
||||
}
|
||||
}
|
||||
|
||||
function getCastColumnQuery(field: string, type: string): string {
|
||||
const db = getDatabaseType(process.env.DATABASE_URL);
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
return `${field}::${type}`;
|
||||
}
|
||||
|
||||
if (db === MYSQL) {
|
||||
return `${field}`;
|
||||
}
|
||||
}
|
||||
|
||||
function getDateQuery(field: string, unit: string, timezone?: string): string {
|
||||
const db = getDatabaseType();
|
||||
|
||||
|
|
@ -177,13 +202,28 @@ function getPageFilters(filters: SearchFilter<any>): [
|
|||
];
|
||||
}
|
||||
|
||||
function getSearchMode(): { mode?: Prisma.QueryMode } {
|
||||
const db = getDatabaseType();
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
return {
|
||||
mode: 'insensitive',
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
export default {
|
||||
...prisma,
|
||||
getAddMinutesQuery,
|
||||
getDayDiffQuery,
|
||||
getCastColumnQuery,
|
||||
getDateQuery,
|
||||
getTimestampIntervalQuery,
|
||||
getFilterQuery,
|
||||
parseFilters,
|
||||
getPageFilters,
|
||||
getSearchMode,
|
||||
rawQuery,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -126,13 +126,8 @@ export interface WebsiteEventMetric {
|
|||
y: number;
|
||||
}
|
||||
|
||||
export interface WebsiteEventDataStats {
|
||||
fieldName: string;
|
||||
dataType: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface WebsiteEventDataFields {
|
||||
export interface WebsiteEventData {
|
||||
eventName?: string;
|
||||
fieldName: string;
|
||||
dataType: number;
|
||||
fieldValue?: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue