Class: Spree::Collections::RegenerateTimeBasedJob
- Defined in:
- app/jobs/spree/collections/regenerate_time_based_job.rb
Overview
Re-evaluates automatic collections whose rules are time-relative (e.g. AvailableOn), which event-driven regeneration can't keep fresh. Scheduled by the host app (sidekiq-cron / solid_queue recurring), the same pattern as Spree::StockReservations::ExpireJob.
Constant Summary
Constants inherited from BaseJob
Instance Method Summary collapse
Instance Method Details
#perform ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/jobs/spree/collections/regenerate_time_based_job.rb', line 9 def perform types = Rails.application.config.spree.time_based_collection_rules.map(&:to_s) time_based = Spree::Collection.automatic. where(id: Spree::CollectionRule.where(type: types).select(:collection_id)) each_store_of(time_based) do |collections| collections.find_each { |collection| Spree::Collections::RegenerateProducts.call(collection: collection) } end end |