Class: SpreeCmCommissioner::StockStatusConsolidationJob
- Inherits:
-
ApplicationUniqueJob
- Object
- ActiveJob::Base
- ApplicationUniqueJob
- ApplicationUniqueJob
- SpreeCmCommissioner::StockStatusConsolidationJob
- Defined in:
- app/jobs/spree_cm_commissioner/stock_status_consolidation_job.rb
Overview
Safety-net reconciliation sweep, run on a low-frequency cron (cm-market-server/config/schedule.yml,
stock_status_consolidation entry, dispatched through the existing InvokeJob cron pattern — same
mechanism already used for WaitingRoom::StampQueuePositionsJob/Integrations::PollingSchedulerJob).
SpreeCmCommissioner::PublishStockStatusesToFirestoreJob (enqueued directly off order-complete, see SpreeCmCommissioner::OrderStateMachine) is the primary, near-instant trigger now. This job exists only to catch anything that trigger misses — a failed job, a Firestore hiccup, or stock changing via a path other than order-complete (e.g. an admin stock adjustment) — by re-scanning every event currently inside its live_stock_starts_at/live_stock_ends_at window (see Spree::Taxon.live_stock_active) regardless of whether anything actually changed. Delegates the actual (batched, per-event) Firestore write to Events::PublishStockStatusesToFirestore, same as the real-time job.
ApplicationUniqueJob (not ApplicationJob) so a cycle that runs long — many live events, a slow
Firestore round trip — can't overlap with the next cron tick a minute later; perform takes no
arguments, so this is a single global "is a consolidation cycle already in flight" lock, same pattern
as WaitingRoom::StampQueuePositionsJob above.
Instance Method Summary collapse
Instance Method Details
#perform ⇒ Object
21 22 23 24 25 |
# File 'app/jobs/spree_cm_commissioner/stock_status_consolidation_job.rb', line 21 def perform Spree::Taxon.event.live_stock_active.find_each do |taxon| SpreeCmCommissioner::Events::PublishStockStatusesToFirestore.call(taxon: taxon) end end |