Class: ScheduleWorkers::Decimals::BackfillTotalAndChargePriceV2OnReservations
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- ScheduleWorkers::Decimals::BackfillTotalAndChargePriceV2OnReservations
- Defined in:
- app/workers/schedule_workers/decimals/backfill_total_and_charge_price_v2_on_reservations.rb
Instance Method Summary collapse
Methods inherited from ApplicationWorker
Instance Method Details
#perform(batch_size = 1000) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/workers/schedule_workers/decimals/backfill_total_and_charge_price_v2_on_reservations.rb', line 4 def perform(batch_size = 1000) ActiveRecord::Base.transaction do # Fetch the next batch of reservations with total_v2_cents = 0 reservations = Reservation.where(total_price_v2_cents: 0).where.not(total_price: 0).last(batch_size) if reservations.blank? # If there are no more reservations to process, we can stop the worker # and exit the transaction APMErrorHandler.report('No more BackfillTotalAndChargePriceV2OnReservations data to process') raise ActiveRecord::Rollback end # Update the reservations in batches update_reservations(reservations) end end |