Class: SpreeCmCommissioner::MaintenanceTasks::RefinalizeGuestsBatchJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- ApplicationJob
- SpreeCmCommissioner::MaintenanceTasks::RefinalizeGuestsBatchJob
- Defined in:
- app/jobs/spree_cm_commissioner/maintenance_tasks/refinalize_guests_batch_job.rb
Instance Method Summary collapse
-
#perform(guest_ids:, event_id:) ⇒ Object
Finalizes (assigns bib numbers to) a batch of guests for an event.
Methods included from ApplicationJobDecorator
handle_deserialization_error, prepended
Instance Method Details
#perform(guest_ids:, event_id:) ⇒ Object
Finalizes (assigns bib numbers to) a batch of guests for an event. Enqueued in slices by Event#refinalize_guests instead of looping over every guest inline, so one event with tens of thousands of guests doesn't block a single job for hours. ApplicationJob handles error logging via around_perform hook.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/jobs/spree_cm_commissioner/maintenance_tasks/refinalize_guests_batch_job.rb', line 11 def perform(guest_ids:, event_id:) event = Spree::Taxon.find_by(id: event_id) return if event.blank? SpreeCmCommissioner::Guest .where(id: guest_ids) .includes(line_item: [{ order: :user }, :variant]) .find_each do |guest| result = SpreeCmCommissioner::Guests::Finalize.call( guest: guest, user: guest.line_item.order.user, event: event, variant: guest.line_item.variant ) next if result.success? CmAppLogger.log( label: "#{self.class.name} failed", data: { guest_id: guest.id, event_id: event_id, error: result.error.to_s } ) end end |