Session properties.

This commit is contained in:
Mike Cao 2024-08-16 19:44:16 -07:00
parent deb9dd60df
commit fc1fc5807e
10 changed files with 64 additions and 22 deletions

View file

@ -1,4 +1,5 @@
import { ClickHouseClient, createClient } from '@clickhouse/client';
import { formatInTimeZone } from 'date-fns-tz';
import debug from 'debug';
import { CLICKHOUSE } from 'lib/db';
import { DEFAULT_PAGE_SIZE, OPERATORS } from './constants';
@ -48,6 +49,10 @@ function getClient() {
return client;
}
function getUTCString(date?: Date) {
return formatInTimeZone(date || new Date(), 'UTC', 'yyyy-MM-dd HH:mm:ss');
}
function getDateStringSQL(data: any, unit: string = 'utc', timezone?: string) {
if (timezone) {
return `formatDateTime(${data}, '${CLICKHOUSE_DATE_FORMATS[unit]}', '${timezone}')`;
@ -221,6 +226,7 @@ export default {
getDateStringSQL,
getDateSQL,
getFilterQuery,
getUTCString,
parseFilters,
pagedQuery,
findUnique,