mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 07:07:17 +01:00
Updated date output for Clickhouse.
This commit is contained in:
parent
62f35668ae
commit
4494665d2e
6 changed files with 20 additions and 17 deletions
|
|
@ -9,11 +9,12 @@ import { maxDate } from './date';
|
|||
import { filtersToArray } from './params';
|
||||
|
||||
export const CLICKHOUSE_DATE_FORMATS = {
|
||||
minute: '%Y-%m-%d %H:%i:00',
|
||||
hour: '%Y-%m-%d %H:00:00',
|
||||
day: '%Y-%m-%d',
|
||||
month: '%Y-%m-01',
|
||||
year: '%Y-01-01',
|
||||
second: '%Y-%m-%dT%H:%i:%S',
|
||||
minute: '%Y-%m-%dT%H:%i:00',
|
||||
hour: '%Y-%m-%dT%H:00:00',
|
||||
day: '%Y-%m-%dT00:00:00',
|
||||
month: '%Y-%m-01T00:00:00',
|
||||
year: '%Y-01-01T00:00:00',
|
||||
};
|
||||
|
||||
const log = debug('umami:clickhouse');
|
||||
|
|
@ -47,7 +48,11 @@ function getClient() {
|
|||
return client;
|
||||
}
|
||||
|
||||
function getDateStringSQL(data: any, unit: string | number) {
|
||||
function getDateStringSQL(data: any, unit: string | number, timezone?: string) {
|
||||
if (timezone) {
|
||||
return `formatDateTime(${data}, '${CLICKHOUSE_DATE_FORMATS[unit]}', '${timezone}')`;
|
||||
}
|
||||
|
||||
return `formatDateTime(${data}, '${CLICKHOUSE_DATE_FORMATS[unit]}')`;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ export function getDateArray(data: any[], startDate: Date, endDate: Date, unit:
|
|||
|
||||
for (let i = 0; i <= n; i++) {
|
||||
const t = start(add(startDate, i));
|
||||
const y = data.find(({ x }) => start(getDateFromString(x)).getTime() === t.getTime())?.y || 0;
|
||||
const y = data.find(({ x }) => start(new Date(x)).getTime() === t.getTime())?.y || 0;
|
||||
|
||||
arr.push({ x: t, y });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue