API+App+Admin: telemetria bytnosci w ogolnym widoku sirowni - GET /gyms/:id/presence-stats (heatmapa dzien×godzina, sredni pobyt, wizyty/dzien, szczyt, teraz w srodku, top urzadzenia; stale 30 dni), wspoldzielony komponent PresenceHeatmap, telemetria wyciagnieta z podstrony statystyk; pasek godzin w forma zegarowa z minutami, usuniete karta Dane i filtr okresu; swagger + testy integracyjne, unit i e2e
This commit is contained in:
@@ -41,6 +41,7 @@ import type {
|
||||
GymContactView,
|
||||
GymInvitation,
|
||||
GymKind,
|
||||
GymPresenceStatsResponse,
|
||||
GymStatsOverview,
|
||||
VirtualGym,
|
||||
Trainee,
|
||||
@@ -221,6 +222,23 @@ export function deleteGymContactMessage(messageId: string) {
|
||||
return api(`/gym-contact/messages/${encodeURIComponent(messageId)}`, { method: 'DELETE' });
|
||||
}
|
||||
|
||||
/**
|
||||
* Telemetria bytności (widok ogólny siłowni REAL): heatmapa dzień×godzina + KPI.
|
||||
* Stały okres 30 dni — bez filtra na widoku ogólnym (rozwinięcie: statystyki właściciela).
|
||||
*/
|
||||
export function useGymPresenceStats(gymId: string | undefined, rangeDays = 30) {
|
||||
return useQuery({
|
||||
queryKey: ['gym-presence-stats', gymId, rangeDays],
|
||||
queryFn: () => {
|
||||
const from = new Date(Date.now() - rangeDays * 86_400_000).toISOString();
|
||||
return api<GymPresenceStatsResponse>(
|
||||
`/gyms/${gymId}/presence-stats?from=${encodeURIComponent(from)}`,
|
||||
);
|
||||
},
|
||||
enabled: !!gymId,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Statystyki właściciela (REAL): presence + członkowie + aktywność treningowa.
|
||||
* `rangeDays`: 7/30/90, from liczony od teraz (jak mapa ciepła urządzeń).
|
||||
|
||||
@@ -353,6 +353,23 @@ export interface GymContactThread {
|
||||
canReply: boolean;
|
||||
}
|
||||
|
||||
// ---------- bytność (GET /gyms/:id/presence-stats, REAL — widok ogólny) ----------
|
||||
export interface GymPresenceStatsData {
|
||||
visits: number;
|
||||
avgStayMinutes: number | null;
|
||||
heatmap: { day: number; hour: number; count: number }[];
|
||||
topGyms: { gymId: string; gymName: string; visits: number }[];
|
||||
peak: number;
|
||||
topEquipment: { equipmentId: string; name: string; nameEn: string | null; count: number }[];
|
||||
live: number;
|
||||
visitsPerDay: number;
|
||||
}
|
||||
|
||||
export interface GymPresenceStatsResponse {
|
||||
gym: { id: string; name: string; kind: GymKind; capacity: number | null };
|
||||
stats: GymPresenceStatsData;
|
||||
}
|
||||
|
||||
// ---------- statystyki właściciela (GET /gyms/:id/stats/overview, REAL) ----------
|
||||
export interface GymStatsOverview {
|
||||
gym: { id: string; name: string; kind: GymKind; capacity: number | null };
|
||||
|
||||
Reference in New Issue
Block a user