fix clickhouse date timezone issues
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { ClickHouse } from 'clickhouse';
|
||||
import { Kafka } from 'kafkajs';
|
||||
import dateFormat from 'dateformat';
|
||||
import chalk from 'chalk';
|
||||
import {
|
||||
MYSQL,
|
||||
@@ -164,13 +165,13 @@ export function getDateQuery(field, unit, timezone) {
|
||||
|
||||
export function getDateQueryClickhouse(field, unit, timezone) {
|
||||
if (timezone) {
|
||||
return `date_trunc('${unit}', ${field},'${timezone}')`;
|
||||
return `date_trunc('${unit}', ${field}, '${timezone}')`;
|
||||
}
|
||||
return `date_trunc('${unit}', ${field})`;
|
||||
}
|
||||
|
||||
export function getDateFormatClickhouse(date) {
|
||||
return `parseDateTimeBestEffort('${date.toUTCString()}')`;
|
||||
return `'${dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss')}'`;
|
||||
}
|
||||
|
||||
export function getBetweenDatesClickhouse(field, start_at, end_at) {
|
||||
@@ -357,3 +358,7 @@ export async function kafkaProducer(params, topic) {
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
export function getDateFormatKafka(date) {
|
||||
return dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user