Class: ItemAttributeRefreshWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/item_attribute_refresh_worker.rb

Overview

Sidekiq worker: item attribute refresh.

Instance Method Summary collapse

Instance Method Details

#performObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/workers/item_attribute_refresh_worker.rb', line 9

def perform
  # Periodically find items who had their specs not refreshed in a while e.g 14 days, do 500 at a time
  item_ids = Item.active.non_publications
                 .where(rendered_product_specifications_at: [..14.days.ago, nil])
                 .order(:is_kit, :rendered_product_specifications_at)
                 .limit(500)
                 .ids

  item_ids.each_slice(BatchItemAttributeWorker::BATCH_SIZE) do |batch|
    BatchItemAttributeWorker.perform_async(batch)
  end
end