Fix share URL permissions. (#1745)

* Fix share URL permissions.

* Add sql param logic.

* Add permissions to edit website.

* Update permissions.

* Move parameters to param injection.

* Sanitize eventdata.

* Remove caret.

* Fix avg.
This commit is contained in:
Brian Cao 2023-01-18 15:09:49 -08:00 committed by GitHub
parent 558ce268a0
commit 922c3acab3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 139 additions and 79 deletions

View file

@ -10,8 +10,8 @@ export async function getSessionMetrics(...args) {
}
async function relationalQuery(websiteId, { startDate, endDate, field, filters = {} }) {
const { parseFilters, rawQuery } = prisma;
const params = [startDate, endDate];
const { parseFilters, rawQuery, toUuid } = prisma;
const params = [websiteId, startDate, endDate];
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(null, filters, params);
return rawQuery(
@ -23,8 +23,8 @@ async function relationalQuery(websiteId, { startDate, endDate, field, filters =
join website
on pageview.website_id = website.website_id
${joinSession}
where website.website_uuid='${websiteId}'
and pageview.created_at between $1 and $2
where website.website_uuid = $1${toUuid()}
and pageview.created_at between $2 and $3
${pageviewQuery}
${sessionQuery}
)