mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
prevent sending multiple reminders for reservations with multiple slots
This commit is contained in:
parent
71a111d8ba
commit
3dea7a63a9
@ -13,9 +13,16 @@ class ReservationReminderWorker
|
|||||||
ending = starting + 1.hour
|
ending = starting + 1.hour
|
||||||
|
|
||||||
Reservation.joins(:slots).where('slots.start_at >= ? AND slots.start_at <= ?', starting, ending).each do |r|
|
Reservation.joins(:slots).where('slots.start_at >= ? AND slots.start_at <= ?', starting, ending).each do |r|
|
||||||
NotificationCenter.call type: 'notify_member_reservation_reminder',
|
already_sent = Notification.where(
|
||||||
receiver: r.user,
|
attached_object_type: Reservation.name,
|
||||||
attached_object: r
|
attached_object_id: r.id,
|
||||||
|
notification_type_id: NotificationType.find_by_name('notify_member_reservation_reminder')
|
||||||
|
).count
|
||||||
|
unless already_sent > 0
|
||||||
|
NotificationCenter.call type: 'notify_member_reservation_reminder',
|
||||||
|
receiver: r.user,
|
||||||
|
attached_object: r
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user