Class: SpreeCmCommissioner::WaitingRoomSession

Inherits:
Base
  • Object
show all
Includes:
StoreMetadata
Defined in:
app/models/spree_cm_commissioner/waiting_room_session.rb

Constant Summary collapse

LOAD_TEST_PAGE_PATH =

k6's waiting_room_flow script (load_testing/tests/platform/waiting_room_flow/_export.js) always sends this fixed page_path — a naming convention on the client side only, not a validated/ stamped server-side flag. guest_identifier isn't a reliable signal: once Firestore is involved the server overwrites it with a real Firebase-issued doc id, discarding whatever the k6 script sent. page_path is never overwritten, so it's the one signal that survives.

'/t/events/load-test-event'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.kill_by_ids!(ids, now = Time.current) ⇒ Object

Kills only the given active sessions (admin picks them individually, Gmail-style) and returns how many. Sets expired_at = now so each row drops out of .active and frees its slot; stamps exit_at = now to mark it a deliberate kill vs a natural timeout.



43
44
45
# File 'app/models/spree_cm_commissioner/waiting_room_session.rb', line 43

def self.kill_by_ids!(ids, now = Time.current)
  active.where(id: ids).update_all(expired_at: now, exit_at: now, updated_at: now) # rubocop:disable Rails/SkipsModelValidations
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/models/spree_cm_commissioner/waiting_room_session.rb', line 55

def active?
  expired_at > Time.current
end

#expired?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/spree_cm_commissioner/waiting_room_session.rb', line 51

def expired?
  expired_at < Time.current
end

#load_test?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/models/spree_cm_commissioner/waiting_room_session.rb', line 47

def load_test?
  page_path == LOAD_TEST_PAGE_PATH
end

#past_ceiling?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/models/spree_cm_commissioner/waiting_room_session.rb', line 59

def past_ceiling?
  max_expired_at.present? && Time.current >= max_expired_at
end