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, });