1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

(bug) event cannot update nb of free places

This commit is contained in:
Du Peng 2023-07-12 12:26:49 +02:00
parent 25d8b25808
commit e8228ce48f

View File

@ -87,11 +87,9 @@ class Event < ApplicationRecord
if nb_total_places.nil?
self.nb_free_places = nil
else
reserved_places = reservations.joins(:slots_reservations)
.where('slots_reservations.canceled_at': nil)
.where('slots_reservations.is_valid': true)
.map(&:total_booked_seats)
.inject(0) { |sum, t| sum + t }
reserved = reservations.joins(:slots_reservations).where('slots_reservations.canceled_at': nil)
reserved = reserved.where('slots_reservations.is_valid': true) if pre_registration?
reserved_places = reserved.map(&:total_booked_seats).inject(0) { |sum, t| sum + t }
self.nb_free_places = (nb_total_places - reserved_places)
end
end