Class: NotificationWorkers::Partner::InventoryWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- NotificationWorkers::Partner::InventoryWorker
- Includes:
- RollbarSynTokenSetterWorker
- Defined in:
- app/workers/notification_workers/partner/inventory_worker.rb
Overview
typed: false frozen_string_literal: true
Instance Method Summary collapse
Methods inherited from ApplicationWorker
Instance Method Details
#perform(reservation_id) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/workers/notification_workers/partner/inventory_worker.rb', line 8 def perform(reservation_id) reservation = Reservation.find_by(id: reservation_id) return if reservation.blank? restaurant = reservation.restaurant inventories = Inventory.by_date.where(restaurant_id: restaurant.id) total_seat = inventories&.sum(:quantity_available) booked_seat = inventories&.sum(:total_booked_seat) return if total_seat.zero? booked_percentage = ((booked_seat / total_seat.to_f) * 100).round if booked_percentage.between?(70, 99) create_allotment_notifcation(restaurant, 70) elsif booked_percentage >= 100 create_allotment_notifcation(restaurant, 100) end end |