Feat/um 49 query builder api (#1573)

* add uuid to event. add indexes

* eventdata api

* add event data

* remove test data

* update list
This commit is contained in:
Brian Cao 2022-10-21 21:33:23 -07:00 committed by GitHub
parent 9c36dc485e
commit ba31f48f1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 690 additions and 64 deletions

View file

@ -12,7 +12,7 @@ export async function getActiveVisitors(...args) {
async function relationalQuery(websiteId) {
const date = subMinutes(new Date(), 5);
const params = [websiteId, date];
const params = [date];
return prisma.rawQuery(
`select count(distinct session_id) x
@ -20,7 +20,7 @@ async function relationalQuery(websiteId) {
join website
on pageview.website_id = website.website_id
where website.website_uuid = '${websiteId}'
and pageview.created_at >= $2`,
and pageview.created_at >= $1`,
params,
);
}

View file

@ -11,7 +11,7 @@ export async function getWebsiteStats(...args) {
async function relationalQuery(websiteId, { start_at, end_at, filters = {} }) {
const { getDateQuery, getTimestampInterval, parseFilters, rawQuery } = prisma;
const params = [websiteId, start_at, end_at];
const params = [start_at, end_at];
const { pageviewQuery, sessionQuery, joinSession } = parseFilters(
'pageview',
null,
@ -34,7 +34,7 @@ async function relationalQuery(websiteId, { start_at, end_at, filters = {} }) {
on pageview.website_id = website.website_id
${joinSession}
where website.website_uuid='${websiteId}'
and pageview.created_at between $2 and $3
and pageview.created_at between $1 and $2
${pageviewQuery}
${sessionQuery}
group by 1, 2