add event-data support and charts for arrays, booleans, dates
This commit is contained in:
1 parent
43fb351ac7
commit
5a1ef5e674
25 files changed
+1205
-62
No files matched your search
@@ -8,7 +8,7 @@ import type { EventPropertyFilter, Operator, QueryFilters, QueryOptions } from '
|
||||
|
||||
export const CLICKHOUSE_DATE_FORMATS = {
|
||||
utc: '%Y-%m-%dT%H:%i:%SZ',
|
||||
second: '%Y-%m-%d %H:%i:%S',
|
||||
second: '%Y-%m-%dT%H:%i:%S',
|
||||
minute: '%Y-%m-%d %H:%i:00',
|
||||
hour: '%Y-%m-%d %H:00:00',
|
||||
day: '%Y-%m-%d',
|
||||
|
||||
@@ -39,6 +39,11 @@ const DATE_FORMATS_UTC = {
|
||||
year: 'YYYY-01-01"T"HH24:00:00"Z"',
|
||||
};
|
||||
|
||||
const DATE_STRING_FORMATS = {
|
||||
utc: 'YYYY-MM-DD"T"HH24:MI:SS"Z"',
|
||||
second: 'YYYY-MM-DD"T"HH24:MI:SS',
|
||||
};
|
||||
|
||||
function getAddIntervalQuery(field: string, interval: string): string {
|
||||
return `${field} + interval '${interval}'`;
|
||||
}
|
||||
@@ -59,6 +64,14 @@ function getDateSQL(field: string, unit: string, timezone?: string): string {
|
||||
return `to_char(date_trunc('${unit}', ${field}), '${DATE_FORMATS_UTC[unit]}')`;
|
||||
}
|
||||
|
||||
function getDateStringSQL(field: string, unit: keyof typeof DATE_STRING_FORMATS = 'utc', timezone?: string): string {
|
||||
if (timezone && timezone !== 'utc') {
|
||||
return `to_char(${field} at time zone '${timezone}', '${DATE_STRING_FORMATS[unit]}')`;
|
||||
}
|
||||
|
||||
return `to_char(${field}, '${DATE_STRING_FORMATS.utc}')`;
|
||||
}
|
||||
|
||||
function getDateWeeklySQL(field: string, timezone?: string) {
|
||||
return `concat(extract(dow from (${field} at time zone '${timezone}')), ':', to_char((${field} at time zone '${timezone}'), 'HH24'))`;
|
||||
}
|
||||
@@ -504,6 +517,7 @@ export default {
|
||||
getCastColumnQuery,
|
||||
getDayDiffQuery,
|
||||
getDateSQL,
|
||||
getDateStringSQL,
|
||||
getDateWeeklySQL,
|
||||
getFilterQuery,
|
||||
getEventPropertyFilterQuery,
|
||||
|
||||
@@ -60,6 +60,25 @@ export interface DynamicData {
|
||||
[key: string]: number | string | number[] | string[];
|
||||
}
|
||||
|
||||
export interface EventDataSeriesPoint {
|
||||
x: string;
|
||||
t: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface EventDataDateSeriesPoint {
|
||||
t: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface EventDataNumericStats {
|
||||
total: number;
|
||||
average: number;
|
||||
median: number;
|
||||
max: number;
|
||||
min: number;
|
||||
}
|
||||
|
||||
export interface QueryOptions {
|
||||
joinSession?: boolean;
|
||||
columns?: Record<string, string>;
|
||||
|
||||
Reference in new issue
Block a user