Event data report UI.

This commit is contained in:
Mike Cao 2023-07-01 22:02:49 -07:00
parent 6316a0b917
commit 9d7862cbd6
36 changed files with 660 additions and 254 deletions

View file

@ -26,7 +26,8 @@ async function relationalQuery(websiteId: string, startDate: Date, endDate: Date
from event_data
where website_id = $1${toUuid()}
and created_at >= $2
and created_at between $3 and $4`,
and created_at between $3 and $4
order by event_key asc`,
params,
);
}
@ -43,7 +44,8 @@ async function clickhouseQuery(websiteId: string, startDate: Date, endDate: Date
from event_data
where website_id = {websiteId:UUID}
and created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('created_at', startDate, endDate)}`,
and ${getBetweenDates('created_at', startDate, endDate)}
order by event_key asc`,
params,
);
}

View file

@ -1,5 +1,5 @@
import { Prisma } from '@prisma/client';
import { DYNAMIC_DATA_TYPE } from 'lib/constants';
import { DATA_TYPE } from 'lib/constants';
import { uuid } from 'lib/crypto';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import { flattenJSON } from 'lib/dynamicData';
@ -38,13 +38,13 @@ async function relationalQuery(data: {
websiteId,
key: a.key,
stringValue:
a.dynamicDataType === DYNAMIC_DATA_TYPE.string ||
a.dynamicDataType === DYNAMIC_DATA_TYPE.boolean ||
a.dynamicDataType === DYNAMIC_DATA_TYPE.array
a.dynamicDataType === DATA_TYPE.string ||
a.dynamicDataType === DATA_TYPE.boolean ||
a.dynamicDataType === DATA_TYPE.array
? a.value
: null,
numericValue: a.dynamicDataType === DYNAMIC_DATA_TYPE.number ? a.value : null,
dateValue: a.dynamicDataType === DYNAMIC_DATA_TYPE.date ? new Date(a.value) : null,
numericValue: a.dynamicDataType === DATA_TYPE.number ? a.value : null,
dateValue: a.dynamicDataType === DATA_TYPE.date ? new Date(a.value) : null,
dataType: a.dynamicDataType,
}));
@ -76,13 +76,13 @@ async function clickhouseQuery(data: {
event_name: eventName,
event_key: a.key,
string_value:
a.dynamicDataType === DYNAMIC_DATA_TYPE.string ||
a.dynamicDataType === DYNAMIC_DATA_TYPE.boolean ||
a.dynamicDataType === DYNAMIC_DATA_TYPE.array
a.dynamicDataType === DATA_TYPE.string ||
a.dynamicDataType === DATA_TYPE.boolean ||
a.dynamicDataType === DATA_TYPE.array
? a.value
: null,
numeric_value: a.dynamicDataType === DYNAMIC_DATA_TYPE.number ? a.value : null,
date_value: a.dynamicDataType === DYNAMIC_DATA_TYPE.date ? getDateFormat(a.value) : null,
numeric_value: a.dynamicDataType === DATA_TYPE.number ? a.value : null,
date_value: a.dynamicDataType === DATA_TYPE.date ? getDateFormat(a.value) : null,
data_type: a.dynamicDataType,
created_at: createdAt,
}));