add domain filter on events

This commit is contained in:
Emily
2025-02-05 16:02:32 +01:00
parent 0963201a32
commit b592695a49
10 changed files with 47 additions and 31 deletions

View File

@@ -16,7 +16,7 @@ export default defineEventHandler(async event => {
const timelineData = await executeTimelineAggregation({
projectId: project_id,
model: EventModel,
from, to, slice, timeOffset, domain, debug: true
from, to, slice, timeOffset, domain
});
return timelineData;
});

View File

@@ -4,12 +4,12 @@ import { executeAdvancedTimelineAggregation } from "~/server/services/TimelineSe
export default defineEventHandler(async event => {
const data = await getRequestDataOld(event, { requireSchema: false, requireSlice: true });
const data = await getRequestData(event, ['GUEST', 'RANGE', 'SLICE', 'DOMAIN']);
if (!data) return;
const { from, to, slice, project_id, timeOffset } = data;
const { from, to, slice, project_id, timeOffset, domain } = data;
return await Redis.useCache({ key: `timeline:events_stacked:${project_id}:${slice}:${from || 'none'}:${to || 'none'}`, exp: TIMELINE_EXPIRE_TIME }, async () => {
return await Redis.useCache({ key: `timeline:events_stacked:${project_id}:${slice}:${from || 'none'}:${to || 'none'}:${domain}`, exp: TIMELINE_EXPIRE_TIME }, async () => {
const timelineStackedEvents = await executeAdvancedTimelineAggregation<{ name: String }>({
model: EventModel,
@@ -17,7 +17,8 @@ export default defineEventHandler(async event => {
from, to, slice,
customProjection: { name: "$_id.name" },
customIdGroup: { name: '$name' },
timeOffset
timeOffset,
domain
})
return timelineStackedEvents;

View File

@@ -10,13 +10,14 @@ export default defineEventHandler(async event => {
const { pid, from, to, slice, project_id, timeOffset, domain } = data;
const cacheKey = `timeline:visits:${pid}:${slice}:${from}:${to}:${domain}`;
const cacheExp = 60;
const cacheExp = 20;
return await Redis.useCacheV2(cacheKey, cacheExp, async () => {
const timelineData = await executeAdvancedTimelineAggregation({
projectId: project_id,
model: VisitModel,
from, to, slice, timeOffset, domain
from, to, slice, timeOffset, domain,
debug: true
});
return timelineData;
});