fetch statistics from the server

This commit is contained in:
Fran Jurmanović
2025-05-30 13:31:48 +02:00
parent 9d388816c3
commit d5f7df3ed0
5 changed files with 85 additions and 158 deletions

View File

@@ -9,7 +9,8 @@ import {
type EventConfig,
type EventRules,
type ServerSettings,
type StateHistory
type StateHistory,
type StateHistoryStats
} from '$models/config';
import type { Server } from '$models/server';
import type { RequestEvent } from '@sveltejs/kit';
@@ -49,6 +50,18 @@ export const getStateHistory = async (
);
};
export const getStateHistoryStats = async (
event: RequestEvent,
serverId: string,
startDate: string,
endDate: string
): Promise<StateHistoryStats> => {
return fetchAPIEvent(
event,
`/server/${serverId}/state-history/statistics?start_date=${startDate}&end_date=${endDate}`
);
};
export const getEventFile = async (event: RequestEvent, serverId: string): Promise<EventConfig> => {
return fetchAPIEvent(event, `/server/${serverId}/config/${configFile.event}`);
};