API: mapa ciepla godzinowa korzystania z urzadzen - GET /gyms/:id/equipment-usage + /admin/gyms/:id/equipment-usage (sesje startowane w oknach bytnosci, filtr okresu 7/30/90 dni)

This commit is contained in:
tisachi
2026-10-23 20:11:38 +02:00
parent c2fa74dd7d
commit 081188afbb
5 changed files with 509 additions and 11 deletions

View File

@@ -555,6 +555,27 @@ export const openapi: Record<string, unknown> = {
},
},
},
'/gyms/{gymId}/equipment-usage': {
get: {
tags: ['Gyms'],
summary:
'Equipment usage heatmap of a gym: rows = equipment, 24 hourly cells aggregated from sessions started within presence windows (default range: last 30 days). REAL visible to all logged-in users; VIRTUAL to managers only (empty — presence is REAL only)',
security: [{ bearerAuth: [] }],
parameters: [
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
{ name: 'from', in: 'query', schema: { type: 'string', format: 'date-time' } },
{ name: 'to', in: 'query', schema: { type: 'string', format: 'date-time' } },
],
responses: {
200: {
description:
'OK, returns { equipment: [{ equipmentId, name, nameEn, cells: [{ hour, count }], peak }] } (sorted by total uses desc)',
},
403: { description: 'VIRTUAL gym and the caller is not a manager' },
404: { description: 'Gym not found' },
},
},
},
'/me/presence': {
get: {
tags: ['Presence'],
@@ -1397,6 +1418,26 @@ export const openapi: Record<string, unknown> = {
},
},
},
'/admin/gyms/{id}/equipment-usage': {
get: {
tags: ['Admin'],
summary:
'Equipment usage heatmap of a gym (admin): rows = equipment, 24 hourly cells aggregated from sessions started within presence windows (default range: last 30 days)',
security: [{ bearerAuth: [] }],
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
{ name: 'from', in: 'query', schema: { type: 'string', format: 'date-time' } },
{ name: 'to', in: 'query', schema: { type: 'string', format: 'date-time' } },
],
responses: {
200: {
description:
'OK, returns { equipment: [{ equipmentId, name, nameEn, cells: [{ hour, count }], peak }] } (sorted by total uses desc)',
},
404: { description: 'Gym not found' },
},
},
},
'/admin/gyms': {
get: {
tags: ['Admin'],