fix projection UI on chart

This commit is contained in:
Emily
2025-03-11 13:24:53 +01:00
parent 45e9a9c6a7
commit be82f7046f
3 changed files with 17 additions and 14 deletions

View File

@@ -220,9 +220,14 @@ function transformResponse(input: { _id: string, count: number }[]) {
const labels = input.map(e => DateService.getChartLabelFromISO(e._id, new Date().getTimezoneOffset(), selectedSlice.value));
if (input.length > 0) allDatesFull.value = input.map(e => e._id.toString());
const todayIndex = input.findIndex(e => new Date(e._id).getTime() > (Date.now() - new Date().getTimezoneOffset() * 1000 * 60));
const current = (Date.now());
//console.log(input.map(e => e._id));
//console.log(new Date(current));
return { data, labels, todayIndex }
const todayIndex = input.findIndex(e => new Date(e._id).getTime() >= current);
//console.log({ todayIndex })
return { data, labels, todayIndex: todayIndex + 1 }
}
function onResponseError(e: any) {
@@ -281,7 +286,6 @@ function onDataReady() {
chartData.value.datasets[1].backgroundColor = [createGradient('#4abde8')];
chartData.value.datasets[2].backgroundColor = [createGradient('#fbbf24')];
(chartData.value.datasets[1] as any).borderSkipped = sessionsData.data.value.data.map((e, i) => {
const todayIndex = eventsData.data.value?.todayIndex || 0;
if (i == todayIndex - 1) return true;

View File

@@ -88,7 +88,7 @@ const avgSessionDuration = computed(() => {
const todayIndex = computed(() => {
if (!visitsData.data.value) return -1;
return visitsData.data.value.input.findIndex(e => new Date(e._id).getTime() > (Date.now() - new Date().getTimezoneOffset() * 1000 * 60));
return visitsData.data.value.input.findIndex(e => new Date(e._id).getTime() > (Date.now()));
})

View File

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