Class: SpreeCmCommissioner::WaitingRoom::PublishLobbyPath

Inherits:
Object
  • Object
show all
Extended by:
ServiceModuleThrowable
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/waiting_room/publish_lobby_path.rb

Overview

Publishes the server-owned waiting-guests records path to the lobby document, so mobile and the waiting-room caller share one source of truth for the date partition instead of each building it from their own (possibly skewed) clock/timezone.

CRON note: ecause we use Time.zone.now to determine the path, it’s important that the CRON job runs at the same timezone as well — otherwise the cron could fire before/after Time.zone.now rolls to the new date. Example: cron: “0 0 * * * Asia/Phnom_Penh”

Caching note: No caching needed since the service is expected to be called once per day so a single daily merge write is negligible.

Instance Method Summary collapse

Methods included from ServiceModuleThrowable

call!

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
# File 'app/services/spree_cm_commissioner/waiting_room/publish_lobby_path.rb', line 19

def call
  # merge: true so we never clobber the lobby's `full` / `available_slots` fields.
  lobby_document.set({ waiting_guests_records_path: records_path }, merge: true)

  success(records_path: records_path)
rescue StandardError => e
  failure(nil, e.message)
end