Class: RecancelTmpReservationWorker

Inherits:
ApplicationWorker show all
Defined in:
app/workers/recancel_tmp_reservation_worker.rb

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#performObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/workers/recancel_tmp_reservation_worker.rb', line 2

def perform
  Reservation.where('active = ? AND (is_temporary = ? OR for_locking_system = ?)', true, true, true)
             .where(created_at: 4.hours.ago..2.hours.ago).find_each do |reservation|

    next unless reservation.valid_to_cancel_temporary_booking?

    reservation.with_lock do
      reservation.audit_comment = 'force cancel because get stuck'
      reservation.mark_as_canceled!
      reservation.save!(validate: false)
    end
  end
end