Class: Workers::Reservations::CancelTemporaryWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- Workers::Reservations::CancelTemporaryWorker
- Defined in:
- app/workers/workers/reservations/cancel_temporary_worker.rb
Overview
This worker is used to cancel temporary reservations that have expired. After user choose date, time, number of guests, and packages, Client app sends request to server to lock reservation for x minutes. If user does not complete the payment within that time, this worker will cancel the reservation.
Instance Method Summary collapse
Methods inherited from ApplicationWorker
Instance Method Details
#perform(reservation_id, session_id) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/workers/workers/reservations/cancel_temporary_worker.rb', line 10 def perform(reservation_id, session_id) reservation = Reservation.find(reservation_id) return unless reservation.temporary_lock? return if reservation.session_id != session_id return unless reservation.valid_to_cancel_temporary_booking? reservation.audit_comment = 'cancel booking because expired locking system' reservation.mark_as_canceled! Retriable.retriable on: [ActiveRecord::Deadlocked], tries: 10 do reservation.save!(validate: false) end end |