diff --git a/dashboard/server/api/timeline/visits.ts b/dashboard/server/api/timeline/visits.ts index f531b2b..00f67aa 100644 --- a/dashboard/server/api/timeline/visits.ts +++ b/dashboard/server/api/timeline/visits.ts @@ -13,11 +13,13 @@ export default defineEventHandler(async event => { const cacheExp = 60; return await Redis.useCacheV2(cacheKey, cacheExp, async () => { + const timelineData = await executeTimelineAggregation({ projectId: project_id, model: VisitModel, - from, to, slice + from, to, slice, }); + const timelineFilledMerged = fillAndMergeTimelineAggregationV2(timelineData, slice, from, to); return timelineFilledMerged; diff --git a/dashboard/server/services/TimelineService.ts b/dashboard/server/services/TimelineService.ts index 8dbb4cc..fd2b2af 100644 --- a/dashboard/server/services/TimelineService.ts +++ b/dashboard/server/services/TimelineService.ts @@ -52,7 +52,7 @@ export async function executeAdvancedTimelineAggregation(options: Advanc ...options.customGroup } }, - { $sort: sort }, + { $sort: { firstDate: 1 } }, { $project: { _id: "$firstDate", @@ -60,9 +60,12 @@ export async function executeAdvancedTimelineAggregation(options: Advanc ...options.customProjection } } - ] + ] as any; if (options.debug === true) { + console.log('---------- SORT ----------') + console.log(JSON.stringify(sort, null, 2)); + console.log('---------- AGGREAGATION ----------') console.log(JSON.stringify(aggregation, null, 2)); }