mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 08:37:13 +01:00
Updated types.
This commit is contained in:
parent
1e0c177fe6
commit
6b9c83381c
12 changed files with 40 additions and 43 deletions
|
|
@ -46,22 +46,22 @@ function getClient() {
|
|||
return client;
|
||||
}
|
||||
|
||||
function getDateStringQuery(data, unit) {
|
||||
function getDateStringQuery(data: any, unit: string | number) {
|
||||
return `formatDateTime(${data}, '${CLICKHOUSE_DATE_FORMATS[unit]}')`;
|
||||
}
|
||||
|
||||
function getDateQuery(field, unit, timezone?) {
|
||||
function getDateQuery(field: string, unit: string, timezone?: string) {
|
||||
if (timezone) {
|
||||
return `date_trunc('${unit}', ${field}, '${timezone}')`;
|
||||
}
|
||||
return `date_trunc('${unit}', ${field})`;
|
||||
}
|
||||
|
||||
function getDateFormat(date) {
|
||||
function getDateFormat(date: Date) {
|
||||
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
|
||||
}
|
||||
|
||||
function mapFilter(column, operator, name, type = 'String') {
|
||||
function mapFilter(column: string, operator: string, name: string, type = 'String') {
|
||||
switch (operator) {
|
||||
case OPERATORS.equals:
|
||||
return `${column} = {${name}:${type}}`;
|
||||
|
|
@ -130,12 +130,10 @@ async function rawQuery(query: string, params: Record<string, unknown> = {}): Pr
|
|||
format: 'JSONEachRow',
|
||||
});
|
||||
|
||||
const data = await resultSet.json();
|
||||
|
||||
return data;
|
||||
return resultSet.json();
|
||||
}
|
||||
|
||||
async function findUnique(data) {
|
||||
async function findUnique(data: any[]) {
|
||||
if (data.length > 1) {
|
||||
throw `${data.length} records found when expecting 1.`;
|
||||
}
|
||||
|
|
@ -143,7 +141,7 @@ async function findUnique(data) {
|
|||
return findFirst(data);
|
||||
}
|
||||
|
||||
async function findFirst(data) {
|
||||
async function findFirst(data: any[]) {
|
||||
return data[0] ?? null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,16 +206,14 @@ function getPageFilters(filters: SearchFilter): [
|
|||
];
|
||||
}
|
||||
|
||||
function getSearchMode(): { mode?: Prisma.QueryMode } {
|
||||
function getQueryMode(): Prisma.QueryMode {
|
||||
const db = getDatabaseType();
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
return {
|
||||
mode: 'insensitive',
|
||||
};
|
||||
return 'insensitive';
|
||||
}
|
||||
|
||||
return {};
|
||||
return 'default';
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
@ -228,6 +226,6 @@ export default {
|
|||
getFilterQuery,
|
||||
parseFilters,
|
||||
getPageFilters,
|
||||
getSearchMode,
|
||||
getQueryMode,
|
||||
rawQuery,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue