Class: SpreeCmCommissioner::PublishStockStatusesToFirestoreJob

Inherits:
ApplicationUniqueJob show all
Defined in:
app/jobs/spree_cm_commissioner/publish_stock_statuses_to_firestore_job.rb

Overview

Fired from SpreeCmCommissioner::InventoryItem#publish_live_stock_status_to_firestore (after_commit), one enqueue per event whose stock actually changed, so publishing is near-instant instead of waiting for the next StockStatusConsolidationJob cron tick.

ApplicationUniqueJob (args-keyed via activejob-uniqueness, on_conflict: :log) so a burst of concurrent stock changes for the same popular event collapses into one in-flight publish per event_id, instead of one job per changed InventoryItem row.

Instance Method Summary collapse

Instance Method Details

#perform(event_id:) ⇒ Object



12
13
14
15
16
17
# File 'app/jobs/spree_cm_commissioner/publish_stock_statuses_to_firestore_job.rb', line 12

def perform(event_id:)
  taxon = Spree::Taxon.find_by(id: event_id)
  return unless taxon

  SpreeCmCommissioner::Events::PublishStockStatusesToFirestore.call(taxon: taxon)
end