Add sql param logic.

This commit is contained in:
Brian Cao 2023-01-16 12:58:51 -08:00
parent cc46cfdcbf
commit d93c2f9dd7
9 changed files with 46 additions and 32 deletions

View file

@ -10,8 +10,8 @@ export async function getPageviewMetrics(...args) {
}
async function relationalQuery(websiteId, { startDate, endDate, column, table, filters = {} }) {
const { rawQuery, parseFilters } = prisma;
const params = [startDate, endDate];
const { rawQuery, parseFilters, toUuid } = prisma;
const params = [websiteId, startDate, endDate];
const { pageviewQuery, sessionQuery, eventQuery, joinSession } = parseFilters(
table,
column,
@ -24,8 +24,8 @@ async function relationalQuery(websiteId, { startDate, endDate, column, table, f
from ${table}
${` join website on ${table}.website_id = website.website_id`}
${joinSession}
where website.website_uuid='${websiteId}'
and ${table}.created_at between $1 and $2
where website.website_uuid = $1${toUuid()}
and ${table}.created_at between $2 and $3
${pageviewQuery}
${joinSession && sessionQuery}
${eventQuery}