This commit is contained in:
Brian Cao 2022-10-31 23:42:37 -07:00
parent 246e4e5f4f
commit 17041efaae
73 changed files with 491 additions and 874 deletions

View file

@ -21,7 +21,7 @@ async function relationalQuery(websiteId, { startDate, endDate, event_name, colu
on event.website_id = website.website_id
join event_data
on event.event_id = event_data.event_id
where website_uuid='${websiteId}'
where website.website_id='${websiteId}'
and event.created_at between $1 and $2
${event_name ? `and event_name = ${event_name}` : ''}
${

View file

@ -28,7 +28,7 @@ async function relationalQuery(
from event
join website
on event.website_id = website.website_id
where website_uuid='${websiteId}'
where website.website_id='${websiteId}'
and event.created_at between $1 and $2
${getFilterQuery('event', filters, params)}
group by 1, 2

View file

@ -13,7 +13,7 @@ function relationalQuery(websites, start_at) {
return prisma.client.event.findMany({
where: {
website: {
websiteUuid: {
id: {
in: websites,
},
},

View file

@ -2,6 +2,7 @@ import { EVENT_NAME_LENGTH, URL_LENGTH } from 'lib/constants';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import kafka from 'lib/kafka';
import prisma from 'lib/prisma';
import { uuid } from 'lib/crypto';
export async function saveEvent(...args) {
return runQuery({
@ -11,10 +12,11 @@ export async function saveEvent(...args) {
}
async function relationalQuery(
{ websiteId },
{ session: { id: sessionId }, eventUuid, url, eventName, eventData },
websiteId,
{ eventId, session: { id: sessionId }, eventUuid, url, eventName, eventData },
) {
const data = {
id: eventId,
websiteId,
sessionId,
url: url?.substring(0, URL_LENGTH),
@ -26,6 +28,7 @@ async function relationalQuery(
data.eventData = {
create: {
eventData: eventData,
id: uuid(),
},
};
}
@ -36,7 +39,7 @@ async function relationalQuery(
}
async function clickhouseQuery(
{ websiteUuid: websiteId },
websiteId,
{ session: { country, sessionUuid, ...sessionArgs }, eventUuid, url, eventName, eventData },
) {
const { getDateFormat, sendMessage } = kafka;