fix event data, remove field implementation for now

This commit is contained in:
Francis Cao 2023-07-31 12:13:10 -07:00
parent 7e112b8469
commit 82f9a42313

View File

@ -27,7 +27,7 @@ async function relationalQuery(
) {
const { rawQuery } = prisma;
const website = await loadWebsite(websiteId);
const { field, event } = filters;
const { event } = filters;
if (event) {
return rawQuery(
@ -35,19 +35,19 @@ async function relationalQuery(
select
we.event_name as event,
ed.event_key as field,
ed.data_type as type,
ed.string_value as value,
count(ed.*) as total
from event_data as ed
inner join website_event as we
on we.event_id = ed.website_event_id
where ed.website_id = {{websiteId:uuid}}
and ed.event_key = {{field}}
where ed.website_id = {{websiteId::uuid}}
and ed.created_at between {{startDate}} and {{endDate}}
and we.event_name = {{event}}
group by ed.event_key, ed.string_value
order by 3 desc, 2 desc, 1 asc
group by we.event_name, ed.event_key, ed.data_type, ed.string_value
order by 1 asc, 2 asc, 3 asc, 4 desc
`,
{ ...filters, websiteId, startDate: maxDate(startDate, website.resetAt), endDate },
{ websiteId, startDate: maxDate(startDate, website.resetAt), endDate, ...filters },
);
}
return rawQuery(
@ -55,18 +55,18 @@ async function relationalQuery(
select
we.event_name as event,
ed.event_key as field,
ed.string_value as value,
ed.data_type as type,
count(ed.*) as total
from event_data as ed
inner join website_event as we
on we.event_id = ed.website_event_id
where ed.website_id = {{websiteId::uuid}}
and ed.event_key = {{field}}
and ed.created_at between {{startDate}} and {{endDate}}
group by we.event_name, ed.event_key, ed.string_value
order by 3 desc, 2 desc, 1 asc
group by we.event_name, ed.event_key, ed.data_type
order by 1 asc, 2 asc
limit 100
`,
{ websiteId, field, startDate: maxDate(startDate, website.resetAt), endDate },
{ websiteId, startDate: maxDate(startDate, website.resetAt), endDate },
);
}