Class: ItemAttributeRefreshWorker

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

Instance Method Summary collapse

Instance Method Details

#performObject



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

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)
                 .pluck(:id)

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