mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
.
This commit is contained in:
@@ -8,7 +8,7 @@ const ready = ref<boolean>(false);
|
||||
const props = defineProps<{ slice: SliceName }>();
|
||||
|
||||
async function loadData() {
|
||||
const response = await useTimelineDataRaw('visits', props.slice);
|
||||
const response = await useVisitsTimeline(props.slice);
|
||||
if (!response) return;
|
||||
const fixed = fixMetrics(response, props.slice);
|
||||
console.log(fixed);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { Slice } from "@services/DateService";
|
||||
import DateService from "@services/DateService";
|
||||
import type { MetricsCounts } from "~/server/api/metrics/[project_id]/counts";
|
||||
import type { VisitsWebsiteAggregated } from "~/server/api/metrics/[project_id]/data/websites";
|
||||
import type { MetricsTimeline } from "~/server/api/metrics/[project_id]/timeline/generic";
|
||||
@@ -14,6 +16,19 @@ export function useFirstInteractionData() {
|
||||
return metricsInfo;
|
||||
}
|
||||
|
||||
export async function useVisitsTimeline(fromDate: string, toDate: string, slice: Slice) {
|
||||
const { from, to } = DateService.prepareDateRange(fromDate, toDate, slice);
|
||||
const activeProject = useActiveProject();
|
||||
const response = await $fetch(
|
||||
`/api/metrics/${activeProject.value?._id}/timeline/visits`, {
|
||||
method: 'POST',
|
||||
...signHeaders({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({ slice, from, to })
|
||||
});
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
export async function useTimelineDataRaw(timelineEndpointName: string, slice: SliceName) {
|
||||
const activeProject = useActiveProject();
|
||||
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export type Slice = 'day' | 'hour' | 'month' | 'year';
|
||||
export type Slice = keyof typeof slicesData;
|
||||
|
||||
const slicesData = {
|
||||
hour: {
|
||||
fromOffset: 1000 * 60 * 60 * 24
|
||||
},
|
||||
day: {
|
||||
fromOffset: 1000 * 60 * 60 * 24 * 7
|
||||
},
|
||||
month: {
|
||||
fromOffset: 1000 * 60 * 60 * 24 * 30 * 12
|
||||
},
|
||||
year: {
|
||||
fromOffset: 1000 * 60 * 60 * 24 * 30 * 12 * 10
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DateService {
|
||||
|
||||
public slicesData = slicesData;
|
||||
|
||||
getDefaultRange(slice: Slice, from?: string, to?: string) {
|
||||
|
||||
}
|
||||
|
||||
getQueryDateRange(slice: Slice) {
|
||||
|
||||
const group: Record<string, any> = {}
|
||||
|
||||
Reference in New Issue
Block a user