Class: ItemLtreeSyncWorker
- Inherits:
-
Object
- Object
- ItemLtreeSyncWorker
- Includes:
- Sidekiq::Worker
- Defined in:
- app/workers/item_ltree_sync_worker.rb
Overview
ItemLtreeSyncWorker - Syncs ltree paths on items after product line/category changes
This worker is triggered when:
- ProductLine ltree paths change (cascades from parent changes)
- ProductCategory ltree paths change
It finds all items associated with the changed product lines/categories
and updates their denormalized ltree paths.
Usage:
ItemLtreeSyncWorker.perform_async(product_line_ids: [1, 2, 3])
ItemLtreeSyncWorker.perform_async(product_category_ids: [5, 6])
Instance Method Summary collapse
Instance Method Details
#perform(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/workers/item_ltree_sync_worker.rb', line 21 def perform( = {}) = .symbolize_keys product_line_ids = Array([:product_line_ids]).map(&:to_i).compact product_category_ids = Array([:product_category_ids]).map(&:to_i).compact if product_line_ids.present? Rails.logger.info "[ItemLtreeSyncWorker] Syncing items for #{product_line_ids.size} product lines" Item.sync_items_for_product_lines!(product_line_ids) end if product_category_ids.present? Rails.logger.info "[ItemLtreeSyncWorker] Syncing items for #{product_category_ids.size} product categories" Item.sync_items_for_product_categories!(product_category_ids) end end |