From d5ca1ab1ef064f318ba75f7dd3db93355bd5d5c4 Mon Sep 17 00:00:00 2001 From: Arthur Dodin Date: Mon, 24 Aug 2026 22:40:52 +0200 Subject: [PATCH] feat: notify permanences members every 5 minutes --- backend/src/controllers/permanence.controller.ts | 2 +- backend/src/services/permanence.service.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/controllers/permanence.controller.ts b/backend/src/controllers/permanence.controller.ts index 7bad452..5aee1f9 100644 --- a/backend/src/controllers/permanence.controller.ts +++ b/backend/src/controllers/permanence.controller.ts @@ -374,7 +374,7 @@ export const sendHourlyNotificationToUsers: AppRequestHandler = async (_req, res return; } - permanence_service.sendNotifications(notifications); + await permanence_service.sendNotifications(notifications); Ok(res, { msg: 'Notifications horaires envoyées avec succès' }); }; diff --git a/backend/src/services/permanence.service.ts b/backend/src/services/permanence.service.ts index c326664..6f182db 100644 --- a/backend/src/services/permanence.service.ts +++ b/backend/src/services/permanence.service.ts @@ -441,8 +441,8 @@ export const getDailyNotifications = async (): Promise => { export const getHourlyNotifications = async (): Promise => { const permanences = await db.query.permanenceSchema.findMany({ where: sql` - ${permanenceSchema.start_at} >= date_trunc('hour', now()) + interval '1 hour' - AND ${permanenceSchema.start_at} < date_trunc('hour', now()) + interval '2 hour' + ${permanenceSchema.start_at} >= now() + interval '1 hour' + AND ${permanenceSchema.start_at} < now() + interval '1 hour 5 minutes' `, orderBy: permanenceSchema.start_at, });