Class: SpreeCmCommissioner::WaitingRoomLobbyMetadataFetcher

Inherits:
Object
  • Object
show all
Includes:
FirestoreConnection
Defined in:
app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb

Overview

Reads the lobby document (waiting_rooms/lobby) — the read-side counterpart to WaitingRoom::PublishLobbyPath. Kept separate from WaitingRoomSystemMetadataFetcher, which owns the unrelated metadata/system document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FirestoreConnection

#firestore, #firestore_available?, #service_account

Constructor Details

#initialize(firestore: nil) ⇒ WaitingRoomLobbyMetadataFetcher



10
11
12
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 10

def initialize(firestore: nil)
  @firestore = firestore if firestore.present?
end

Instance Attribute Details

#document_dataObject (readonly)

Returns the value of attribute document_data.



8
9
10
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 8

def document_data
  @document_data
end

Instance Method Details

#available_slotsObject

written by Admission::CallGuests#mark_as.



35
36
37
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 35

def available_slots
  document_data[:available_slots]
end

#documentObject



45
46
47
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 45

def document
  @document ||= firestore.col('waiting_rooms').doc('lobby')
end

#frontier_positionObject

written by Positions::Stamp -- every position up to and including this one is resolved (granted or left). "N people ahead of you" for a stamped guest = their position minus this.



41
42
43
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 41

def frontier_position
  document_data[:frontier_position]
end

#fullObject

written by Admission::CallGuests#mark_as.



30
31
32
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 30

def full
  document_data[:full]
end

#load_document_dataObject

Environments without the credential (dev, test, CI) get an empty document instead of a NoMethodError on a nil service_account -- every accessor below already treats a missing key in document_data as "unknown" (nil/false), so an empty hash here is a real, valid state, not a special case each of them has to know about.



18
19
20
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 18

def load_document_data
  @document_data = firestore_available? ? (document.get.data || {}) : {}
end

#waiting_guests_records_pathObject

server-owned date partition — see WaitingRoom::PublishLobbyPath.



25
26
27
# File 'app/services/spree_cm_commissioner/waiting_room_lobby_metadata_fetcher.rb', line 25

def waiting_guests_records_path
  document_data[:waiting_guests_records_path]
end