Class: SpreeCmCommissioner::WaitingRoom::StampQueuePositions
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::WaitingRoom::StampQueuePositions
- Extended by:
- ServiceModuleThrowable
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/waiting_room/stamp_queue_positions.rb
Overview
Stamps queue positions onto waiting-guest Firestore docs so the app can render each guest’s place in line and a forward-only progress bar. Walks the day partitions oldest-first, assigning a continuous global position (1, 2, 3, …) capped at STAMP_LIMIT, and commits in Firestore batches to stay under the 10 MiB/commit payload bound.
Constant Summary collapse
- STAMP_LIMIT =
(ENV['WAITING_ROOM_POSITION_STAMP_LIMIT'] || 1000).to_i
- FIRESTORE_BATCH_SIZE =
Firestore bounds a batch update by payload size (10 MiB); this batch size leaves 500/commit far under that.
(ENV['WAITING_ROOM_FIRESTORE_BATCH_SIZE'] || 500).to_i
- MAX_WAIT_TO_DISPLAY_SECONDS =
Above this we leave estimated_wait_seconds nil so the app hides the ETA rather than showing a discouraging “~2 hours”. Deep guests just see the coarse “lots ahead” state.
(ENV['WAITING_ROOM_MAX_WAIT_TO_DISPLAY_SECONDS'] || 3600).to_i
- CALLER_INTERVAL_SECONDS =
How often the caller runs and releases one batch. See schedule.yml for WaitingGuestsCallerJob.
(ENV['WAITING_ROOM_CALLER_INTERVAL_SECONDS'] || 60).to_i
- MAX_ETA_BATCH_SIZE =
Caps the batch size assumed when estimating the ETA (not a release limit). The lobby’s slots_per_call is a single run’s available_slots, which spikes on cold starts / lulls (active_sessions low → available_slots ≈ max_sessions). An uncapped spike collapses hundreds of positions into batch 1 and under-promises the wait, so we bound it to keep ETAs conservative. Tune to roughly the real per-minute release capacity.
(ENV['WAITING_ROOM_MAX_ETA_BATCH_SIZE'] || 50).to_i
Instance Method Summary collapse
Methods included from ServiceModuleThrowable
Instance Method Details
#call ⇒ Object
32 33 34 35 36 37 |
# File 'app/services/spree_cm_commissioner/waiting_room/stamp_queue_positions.rb', line 32 def call stamp_positions success(stamped: @stamped.to_i) rescue StandardError => e failure(nil, e.) end |