1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

(bug) event reserved places compute error

This commit is contained in:
Du Peng 2023-07-13 15:04:57 +02:00
parent d22c3db4c2
commit e4b996654b
2 changed files with 7 additions and 2 deletions

View File

@ -2,7 +2,8 @@
- Fix a bug: unable to confirm payment of store for admin
- Fix a bug: unable to update payment schedule item
- Fix a bug: event reserved places compute error
- [TODO DEPLOY] `rails fablab:setup:build_places_cache`
## v6.0.9 2023 July 07

View File

@ -30,10 +30,14 @@ class Slots::PlacesCacheService
reservations = Slots::ReservationsService.reservations(slot.slots_reservations, [reservable])
pending = Slots::ReservationsService.pending_reservations(slot.cart_item_reservation_slots.map(&:id), [reservable])
reserved_places = (reservations[:reservations].count || 0) + (pending[:reservations].count || 0)
if slot.availability.available_type == 'event'
reserved_places = slot.availability.event.nb_total_places - slot.availability.event.nb_free_places
end
places.push({
reservable_type: reservable.class.name,
reservable_id: reservable.try(&:id),
reserved_places: (reservations[:reservations].count || 0) + (pending[:reservations].count || 0),
reserved_places: reserved_places,
user_ids: reservations[:user_ids] + pending[:user_ids]
})
end