Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add 30s delay to AutoMatchTaxonsJob (#13956)

Damian Legawiecf3243dee9113
diff --git a/spree/core/app/models/spree/product.rb b/spree/core/app/models/spree/product.rb
index 89a5c0f048..45d86b1595 100644
--- a/spree/core/app/models/spree/product.rb
+++ b/spree/core/app/models/spree/product.rb
@@ -249,16 +249,11 @@ module Spree
products_to_auto_match_ids = store.products.not_deleted.not_archived.where(id: product_ids).ids
- # for ActiveJob 7.1+
- if ActiveJob.respond_to?(:perform_all_later)
- auto_match_taxons_jobs = products_to_auto_match_ids.map do |product_id|
- Spree::Products::AutoMatchTaxonsJob.new(product_id)
- end
-
- ActiveJob.perform_all_later(auto_match_taxons_jobs)
- else
- products_to_auto_match_ids.each { |product_id| Spree::Products::AutoMatchTaxonsJob.perform_later(product_id) }
+ auto_match_taxons_jobs = products_to_auto_match_ids.map do |product_id|
+ Spree::Products::AutoMatchTaxonsJob.new(product_id).tap { |job| job.scheduled_at = 30.seconds.from_now }
end
+
+ ActiveJob.perform_all_later(auto_match_taxons_jobs)
end
# Can't use short form block syntax due to https://github.com/Netflix/fast_jsonapi/issues/259
@@ -582,7 +577,7 @@ module Spree
store = stores.find_by(default: true) || stores.first
return if store.nil? || store.taxons.automatic.none?
- Spree::Products::AutoMatchTaxonsJob.perform_later(id)
+ Spree::Products::AutoMatchTaxonsJob.set(wait: 30.seconds).perform_later(id)
end
def to_csv(store = nil)