WebsiteId query param. Fix Prisma filters.
This commit is contained in:
@@ -38,23 +38,23 @@ async function relationalQuery(
|
||||
},
|
||||
) {
|
||||
const { startDate, endDate, eventName, columns, filters } = data;
|
||||
const { rawQuery, getEventDataColumnsQuery, getEventDataFilterQuery } = prisma;
|
||||
const params = [startDate, endDate];
|
||||
const { toUuid, rawQuery, getEventDataColumnsQuery, getEventDataFilterQuery } = prisma;
|
||||
const params: any = [websiteId, startDate, endDate, eventName];
|
||||
|
||||
return rawQuery(
|
||||
`select
|
||||
${getEventDataColumnsQuery('event_data', columns)}
|
||||
from website_event
|
||||
where website_id ='${websiteId}'
|
||||
and created_at between $1 and $2
|
||||
where website_id = $1${toUuid()}
|
||||
and created_at between $2 and $3
|
||||
and event_type = ${EVENT_TYPE.customEvent}
|
||||
${eventName ? `and eventName = ${eventName}` : ''}
|
||||
${eventName ? `and eventName = $4` : ''}
|
||||
${
|
||||
Object.keys(filters).length > 0
|
||||
? `and ${getEventDataFilterQuery('event_data', filters)}`
|
||||
: ''
|
||||
}`,
|
||||
params as any,
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ async function relationalQuery(
|
||||
};
|
||||
},
|
||||
) {
|
||||
const { rawQuery, getDateQuery, getFilterQuery } = prisma;
|
||||
const params = [startDate, endDate];
|
||||
const { toUuid, rawQuery, getDateQuery, getFilterQuery } = prisma;
|
||||
const params: any = [websiteId, startDate, endDate];
|
||||
|
||||
return rawQuery(
|
||||
`select
|
||||
@@ -54,8 +54,8 @@ async function relationalQuery(
|
||||
${getDateQuery('created_at', unit, timezone)} t,
|
||||
count(*) y
|
||||
from website_event
|
||||
where website_id='${websiteId}'
|
||||
and created_at between $1 and $2
|
||||
where website_id = $1${toUuid()}
|
||||
and created_at between $2 and $3
|
||||
and event_type = ${EVENT_TYPE.customEvent}
|
||||
${getFilterQuery(filters, params)}
|
||||
group by 1, 2
|
||||
|
||||
Reference in New Issue
Block a user