Class: SpreeCmCommissioner::MaintenanceTasks::GuestDataFillStage

Inherits:
SpreeCmCommissioner::MaintenanceTask show all
Defined in:
app/models/spree_cm_commissioner/maintenance_tasks/guest_data_fill_stage.rb

Constant Summary collapse

BATCH_SIZE =
ENV.fetch('MAINTENANCE_TASKS_GUEST_DATA_FILL_STAGE_BATCH_SIZE', '300').to_i

Constants inherited from SpreeCmCommissioner::MaintenanceTask

SpreeCmCommissioner::MaintenanceTask::MAX_ATTEMPTS

Instance Method Summary collapse

Methods inherited from SpreeCmCommissioner::MaintenanceTask

#async_execute, #execute

Instance Method Details

#maintainObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/spree_cm_commissioner/maintenance_tasks/guest_data_fill_stage.rb', line 6

def maintain
  product = maintainable

  SpreeCmCommissioner::Guest
    .joins(line_item: %i[variant order])
    .where(spree_variants: { product_id: product.id })
    .merge(Spree::Order.complete)
    .order(:id)
    .pluck(:id)
    .each_slice(BATCH_SIZE) do |guest_ids|
      SpreeCmCommissioner::MaintenanceTasks::GuestDataFillStageBatchJob.perform_later(guest_ids: guest_ids, notify: true)
    end
end