mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
add selfhosted env + start fix dates
This commit is contained in:
@@ -4,7 +4,7 @@ import { VisitModel } from "@schema/metrics/VisitSchema";
|
||||
import { Redis } from "~/server/services/CacheService";
|
||||
import DateService from "@services/DateService";
|
||||
|
||||
import { checkSliceValidity, generateDateSlices } from "~/server/services/TimelineService";
|
||||
import { checkSliceValidity } from "~/server/services/TimelineService";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default defineEventHandler(async event => {
|
||||
const [sliceValid, errorOrDays] = checkSliceValidity(from, to, slice);
|
||||
if (!sliceValid) throw Error(errorOrDays);
|
||||
|
||||
const allDates = generateDateSlices(slice, new Date(from), new Date(to));
|
||||
const allDates = DateService.generateDateSlices(slice, new Date(from), new Date(to));
|
||||
|
||||
const result: { _id: string, count: number }[] = [];
|
||||
|
||||
|
||||
@@ -13,12 +13,15 @@ export default defineEventHandler(async event => {
|
||||
const cacheExp = 60;
|
||||
|
||||
return await Redis.useCacheV2(cacheKey, cacheExp, async () => {
|
||||
|
||||
const timelineData = await executeTimelineAggregation({
|
||||
projectId: project_id,
|
||||
model: EventModel,
|
||||
from, to, slice,
|
||||
});
|
||||
|
||||
const timelineFilledMerged = fillAndMergeTimelineAggregationV2(timelineData, slice, from, to);
|
||||
|
||||
return timelineFilledMerged;
|
||||
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ export default defineEventHandler(async event => {
|
||||
const cacheKey = `timeline:visits:${pid}:${slice}:${from}:${to}`;
|
||||
const cacheExp = 60;
|
||||
|
||||
return await Redis.useCacheV2(cacheKey, cacheExp, async () => {
|
||||
return await Redis.useCacheV2(cacheKey, cacheExp, async () => {
|
||||
|
||||
const timelineData = await executeTimelineAggregation({
|
||||
projectId: project_id,
|
||||
@@ -23,7 +23,7 @@ export default defineEventHandler(async event => {
|
||||
const timelineFilledMerged = fillAndMergeTimelineAggregationV2(timelineData, slice, from, to);
|
||||
return timelineFilledMerged;
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user