Class: ScheduleWorkers::Decimals::BackfillChargeAmountV2OnCharges
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- ScheduleWorkers::Decimals::BackfillChargeAmountV2OnCharges
- Defined in:
- app/workers/schedule_workers/decimals/backfill_charge_amount_v2_on_charges.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_charge_amount_v2_on_charges.rb', line 4 def perform(batch_size = 1000) ActiveRecord::Base.transaction do # Fetch the next batch of charges with amount_v2_cents = 0 charges = Externals::Omise::Charge.where(amount_v2_cents: 0).where.not(amount: 0).last(batch_size) if charges.blank? # If there are no more charges to process, we can stop the worker # and exit the transaction APMErrorHandler.report('No more BackfillChargeAmountV2OnCharges data to process') raise ActiveRecord::Rollback end # Update the charges in batches update_charges(charges) end end |