spree_cm_commissioner 2.8.4 → 2.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0a4ffeafedfee096e97e6b76497164146a69fca87cbc28a16309b08c018c079
4
- data.tar.gz: 70d303ce8d2d1e66425c106ede7fd7ae81bbefa355027bbca0a570e996466ebd
3
+ metadata.gz: 6e0eefab5835ceff321c9b4ce873ba5a2aea6f32d7ab13195bf83051d935957e
4
+ data.tar.gz: 62e1cf733e8426992e1bf355a54e0010e48d9fcb09d9bc72313b7dcfada2eca5
5
5
  SHA512:
6
- metadata.gz: 134937bcd74efecb6a2d3a0a23c77f358d16fd00e3100dd28f88a52435fe92afd1ac480674c8f5babe379e42898fa497dd7e1966836c091fd9bfa02465b96080
7
- data.tar.gz: a810dac72b6fddce0c15f422c7b082e63f522bdefbf4893694204462109de870e56dabc9d49e4c0d3eb8fb58127dae673f184b173885e40aea6a9c0b6e1e2c66
6
+ metadata.gz: 1d86efc8f94247aa4aa5d41717dad69cad40411db0f6140cc0f20b9e8b90ef3c040907e03f23b10c04fa357de458fed00ebb822644022db247655c674ccf021d
7
+ data.tar.gz: f91f5e7f163fcc60e716fe5582363720a5842fca70d2b9993dbc2945e13d9eb4db0ae0dd7b1de658fe06b72b021f0e3a65e4011e8292a4c677f38debf886f237
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.8.4)
37
+ spree_cm_commissioner (2.8.5)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -6,6 +6,9 @@ module SpreeCmCommissioner
6
6
  MIN_WAIT_TO_ENTER_SECONDS = 120 # 2 min floor — Waiting Room step (full journey, more uncertainty)
7
7
  MIN_QUEUE_TO_ENTER_SECONDS = 60 # 1 min floor — Queue step (position assigned, one caller cycle minimum)
8
8
 
9
+ # Firestore bounds a batch update by payload size (10 MiB); 500 ops/commit leaves us far under that.
10
+ FIRESTORE_BATCH_SIZE = (ENV['WAITING_ROOM_FIRESTORE_BATCH_SIZE'] || 500).to_i
11
+
9
12
  def call
10
13
  available_slots = fetch_available_slots
11
14
  return unless available_slots.positive?
@@ -70,11 +73,17 @@ module SpreeCmCommissioner
70
73
 
71
74
  # For alert waiting guests to enter room, we just update :allow_to_enter_room_at.
72
75
  # App will listen to firebase & start refresh session token to enter room.
76
+ #
77
+ # Commit in Firestore batches (chunks of FIRESTORE_BATCH_SIZE) instead of one update per guest,
78
+ # so e.g. 1000 guests = 2 commits, not 1000 round-trips. update merges, so we only send the
79
+ # changed field and leave the rest of each doc intact.
73
80
  def calling_all(waiting_guests)
74
- waiting_guests.each do |document|
75
- data = document.data.dup
76
- data[:allow_to_enter_room_at] = Time.zone.now
77
- document.ref.update(data)
81
+ allow_at = Time.zone.now
82
+
83
+ waiting_guests.each_slice(FIRESTORE_BATCH_SIZE) do |slice|
84
+ firestore.batch do |b|
85
+ slice.each { |document| b.update(document.ref, allow_to_enter_room_at: allow_at) }
86
+ end
78
87
  end
79
88
  end
80
89
 
@@ -2,7 +2,7 @@
2
2
  # cron: "*/1 * * * *" # Every minute
3
3
  # class: "SpreeCmCommissioner::WaitingGuestsCallerJob"
4
4
  module SpreeCmCommissioner
5
- class WaitingGuestsCallerJob < ApplicationJob
5
+ class WaitingGuestsCallerJob < ApplicationUniqueJob
6
6
  queue_as :waiting_room
7
7
 
8
8
  def perform
@@ -3,7 +3,7 @@
3
3
  # class: "SpreeCmCommissioner::WaitingRoom::PublishLobbyPathJob"
4
4
  module SpreeCmCommissioner
5
5
  module WaitingRoom
6
- class PublishLobbyPathJob < ApplicationJob
6
+ class PublishLobbyPathJob < ApplicationUniqueJob
7
7
  queue_as :waiting_room
8
8
 
9
9
  def perform
@@ -1,6 +1,6 @@
1
1
  module SpreeCmCommissioner
2
2
  module WaitingRoom
3
- class StampQueuePositionsJob < ApplicationJob
3
+ class StampQueuePositionsJob < ApplicationUniqueJob
4
4
  queue_as :waiting_room
5
5
 
6
6
  def perform
@@ -2,7 +2,7 @@
2
2
  # cron: "*/30 * * * *" # Every 30 minute
3
3
  # class: "SpreeCmCommissioner::WaitingRoomLatestSystemMetadataPuller"
4
4
  module SpreeCmCommissioner
5
- class WaitingRoomLatestSystemMetadataPullerJob < ApplicationJob
5
+ class WaitingRoomLatestSystemMetadataPullerJob < ApplicationUniqueJob
6
6
  queue_as :waiting_room
7
7
 
8
8
  def perform
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.8.4'.freeze
2
+ VERSION = '2.8.5'.freeze
3
3
 
4
4
  module_function
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_cm_commissioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.4
4
+ version: 2.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - You