mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2026-01-17 16:12:25 +01:00
fix:#3 fetch room occupancy once
This commit is contained in:
@@ -86,7 +86,7 @@ const { data: occupations } = useQuery({
|
||||
showFree: event.free,
|
||||
})),
|
||||
enabled: () => selectedRoom.value !== "" && currentDateFrom.value !== "",
|
||||
staleTime: 5000000, // 500 seconds
|
||||
staleTime: 5000000, // 5000 seconds
|
||||
});
|
||||
|
||||
watch(occupations, () => fullCalendar.value?.getApi().refetchEvents());
|
||||
|
||||
@@ -87,16 +87,16 @@ function transformData(data: RoomOccupancyList) {
|
||||
return events;
|
||||
}
|
||||
|
||||
const { data: occupations } = useQuery({
|
||||
queryKey: ["roomOccupation", selectedRoom, currentDateFrom, currentDateTo],
|
||||
const { data: occupancy } = useQuery({
|
||||
queryKey: ["roomOccupancy"],//, selectedRoom, currentDateFrom, currentDateTo],
|
||||
queryFn: () =>
|
||||
fetchRoomOccupancy(
|
||||
new Date(currentDateFrom.value).toISOString(),
|
||||
new Date(currentDateTo.value).toISOString()
|
||||
),
|
||||
select: (data) => transformData(data),
|
||||
enabled: () => selectedRoom.value !== "" && currentDateFrom.value !== "",
|
||||
staleTime: 5000000, // 500 seconds
|
||||
fetchRoomOccupancy(),
|
||||
staleTime: 12 * 3600000, // 12 hours
|
||||
});
|
||||
|
||||
const occupations = computed(() => {
|
||||
if (!occupancy.value) return;
|
||||
return transformData(occupancy.value);
|
||||
});
|
||||
|
||||
watch(occupations, () => fullCalendar.value?.getApi().refetchEvents());
|
||||
|
||||
Reference in New Issue
Block a user