mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
PR comments
This commit is contained in:
parent
1c26581cd1
commit
f569055771
3 changed files with 21 additions and 26 deletions
14
lib/db.js
14
lib/db.js
|
|
@ -29,7 +29,7 @@ function logQuery(e) {
|
|||
console.log(chalk.yellow(e.params), '->', e.query, chalk.greenBright(`${e.duration}ms`));
|
||||
}
|
||||
|
||||
function initializePrisma(options) {
|
||||
function getPrismaClient(options) {
|
||||
const prisma = new PrismaClient(options);
|
||||
|
||||
if (process.env.LOG_QUERY) {
|
||||
|
|
@ -39,7 +39,7 @@ function initializePrisma(options) {
|
|||
return prisma;
|
||||
}
|
||||
|
||||
function initializeClickhouse() {
|
||||
function getClickhouseClient() {
|
||||
if (!process.env.ANALYTICS_URL) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -63,8 +63,8 @@ function initializeClickhouse() {
|
|||
});
|
||||
}
|
||||
|
||||
const prisma = global.prisma || initializePrisma(options);
|
||||
const clickhouse = global.clickhouse || initializeClickhouse();
|
||||
const prisma = global.prisma || getPrismaClient(options);
|
||||
const clickhouse = global.clickhouse || getClickhouseClient();
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
global.prisma = prisma;
|
||||
|
|
@ -142,15 +142,15 @@ export function getBetweenDatesClickhouse(field, start_at, end_at) {
|
|||
and ${getDateFormatClickhouse(end_at)}`;
|
||||
}
|
||||
|
||||
export function getTimestampInterval(maxColumn, minColumn) {
|
||||
export function getTimestampInterval(field) {
|
||||
const db = getDatabase();
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
return `floor(extract(epoch from (${maxColumn}) - (${minColumn})))`;
|
||||
return `floor(extract(epoch from max(${field}) - min(${field})))`;
|
||||
}
|
||||
|
||||
if (db === MYSQL) {
|
||||
return `floor(unix_timestamp(${maxColumn}) - unix_timestamp(${minColumn}))`;
|
||||
return `floor(unix_timestamp(max(${field})) - unix_timestamp(min(${field})))`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue