mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
fix date sort
This commit is contained in:
@@ -13,11 +13,13 @@ export default defineEventHandler(async event => {
|
|||||||
const cacheExp = 60;
|
const cacheExp = 60;
|
||||||
|
|
||||||
return await Redis.useCacheV2(cacheKey, cacheExp, async () => {
|
return await Redis.useCacheV2(cacheKey, cacheExp, async () => {
|
||||||
|
|
||||||
const timelineData = await executeTimelineAggregation({
|
const timelineData = await executeTimelineAggregation({
|
||||||
projectId: project_id,
|
projectId: project_id,
|
||||||
model: VisitModel,
|
model: VisitModel,
|
||||||
from, to, slice
|
from, to, slice,
|
||||||
});
|
});
|
||||||
|
|
||||||
const timelineFilledMerged = fillAndMergeTimelineAggregationV2(timelineData, slice, from, to);
|
const timelineFilledMerged = fillAndMergeTimelineAggregationV2(timelineData, slice, from, to);
|
||||||
return timelineFilledMerged;
|
return timelineFilledMerged;
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export async function executeAdvancedTimelineAggregation<T = {}>(options: Advanc
|
|||||||
...options.customGroup
|
...options.customGroup
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ $sort: sort },
|
{ $sort: { firstDate: 1 } },
|
||||||
{
|
{
|
||||||
$project: {
|
$project: {
|
||||||
_id: "$firstDate",
|
_id: "$firstDate",
|
||||||
@@ -60,9 +60,12 @@ export async function executeAdvancedTimelineAggregation<T = {}>(options: Advanc
|
|||||||
...options.customProjection
|
...options.customProjection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
] as any;
|
||||||
|
|
||||||
if (options.debug === true) {
|
if (options.debug === true) {
|
||||||
|
console.log('---------- SORT ----------')
|
||||||
|
console.log(JSON.stringify(sort, null, 2));
|
||||||
|
console.log('---------- AGGREAGATION ----------')
|
||||||
console.log(JSON.stringify(aggregation, null, 2));
|
console.log(JSON.stringify(aggregation, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user