spree_cm_commissioner 2.3.0.pre.pre13 → 2.3.0.pre.pre16

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: 73859341eaf0edcf92dac1f96263e96851c6bcf3abdcc1fbe9a7932e5f54b87e
4
- data.tar.gz: 789a5ae8b0c79b0eee1edc1baa6ab3edcb4c8d00a8a17926621c62e868b53203
3
+ metadata.gz: 654baee3237bba36ebcc85458b09f73b076c6d1ffb782351cf697fa7ab287c7d
4
+ data.tar.gz: ef9275e9c3d748cdd7947780dca206ea2ae75b4362731e9d9d1b04b2eab04aee
5
5
  SHA512:
6
- metadata.gz: e2f36f2e4874baaa20f5d5cd6b5ea1a68fee7c7cb859b02f9f423491e731523116fa4b0daf55b55d6006db67dd2fde0c27e41ebf05d27f0f28c5694b96bdd99f
7
- data.tar.gz: 89af65da272aecd3820f0fadd0b7863db306b6d14d7eba9ef1ac38959a1b8f0c2f4b22cb201be747ef2312a74f685468a1dfce36673a928ef1a655c9812c903d
6
+ metadata.gz: b35dd2fe6fc1815f72f0c1e33a88eb629437040de5ea73fc48f8cb249b6f322aedfe2be423847b74ef609a78783f62de13399b0c17c6fdebdf0c54c4a826cdf8
7
+ data.tar.gz: 11131275c0fc9afec3d0ed082e10ac0471490e07fc04ebbc64ccb10d01ac1442acb102fd4178bfedad3a0e685939df1ad42459f5c62494dd168c699cbb105b57
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.3.0.pre.pre13)
37
+ spree_cm_commissioner (2.3.0.pre.pre16)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -1,5 +1,28 @@
1
1
  module SpreeCmCommissioner
2
- class WaitingRoomSessionFirebaseLoggerJob < ApplicationJob
2
+ # Logs waiting room session data to Firebase asynchronously.
3
+ #
4
+ # Called from WaitingRoomSessionCreator#log_to_firebase after user enters waiting room.
5
+ # Allows main request to complete without waiting for Firebase I/O.
6
+ #
7
+ # == Retry Configuration
8
+ #
9
+ # Retries on StandardError with exponential backoff: 4 attempts total (1 initial + 3 retries)
10
+ #
11
+ # retry_on StandardError, wait: :exponentially_longer, attempts: 4
12
+ #
13
+ # Wait times: ~1s, ~10s, ~100s
14
+ # Rationale: Balances reliability vs resources. Firebase is generally reliable, so 3 retries
15
+ # is sufficient. Exponential backoff gives service time to recover and reduces load during outages.
16
+ #
17
+ # == Implementation Details
18
+ #
19
+ # - Uses ActiveJob's retry_on (works with any queue adapter: Sidekiq, Resque, etc.)
20
+ # - Inherits from ApplicationUniqueJob (prevents duplicate Firebase writes)
21
+ # - On failure after 4 attempts: moved to dead letter queue, logged for investigation
22
+ #
23
+ class WaitingRoomSessionFirebaseLoggerJob < ApplicationUniqueJob
24
+ retry_on StandardError, wait: :exponentially_longer, attempts: 4
25
+
3
26
  def perform(options)
4
27
  room_session = SpreeCmCommissioner::WaitingRoomSession.find(options[:room_session_id])
5
28
  waiting_guest_firebase_doc_id = options[:waiting_guest_firebase_doc_id]
@@ -23,13 +23,26 @@ module SpreeCmCommissioner
23
23
  # Makes sure seat blocks are held if not held yet or if the hold has expired.
24
24
  # Called before moving to payment state to ensure seats are held properly,
25
25
  # even if hold was started from :address state or an old hold expired.
26
- def ensure_blocks_held!
26
+ def ensure_blocks_held
27
27
  return unless should_manage_blocks?
28
28
  return if hold_expires_at.present? && hold_expires_at > Time.zone.now
29
29
 
30
+ hold_blocks
31
+ end
32
+
33
+ def hold_blocks
30
34
  hold_blocks!
35
+ rescue SpreeCmCommissioner::Seats::BlocksAreReservedByOtherGuestError,
36
+ SpreeCmCommissioner::Seats::BlocksAreOnHoldByOtherGuestError,
37
+ SpreeCmCommissioner::Seats::BlocksAreReservedBySameGuestError,
38
+ SpreeCmCommissioner::Seats::UnableToSaveReservedBlockRecordError => e
39
+ errors.add(:seats, e.message)
40
+ false
31
41
  end
32
42
 
43
+ # Hold blocks for the order. Called during checkout (user-initiated).
44
+ # Catches seat errors and adds them to order.errors to prevent state transition.
45
+ # Returns false if error occurs, true otherwise.
33
46
  def hold_blocks!
34
47
  return unless should_manage_blocks?
35
48
 
@@ -46,6 +59,8 @@ module SpreeCmCommissioner
46
59
  end
47
60
  end
48
61
 
62
+ # Cancel blocks for the order. Called from system (order cancellation/archive).
63
+ # Raises errors to alert the system if something goes wrong.
49
64
  def cancel_blocks!
50
65
  return unless should_manage_blocks?
51
66
 
@@ -55,6 +70,8 @@ module SpreeCmCommissioner
55
70
  end
56
71
  end
57
72
 
73
+ # Reserve blocks for the order. Called from system (order completion).
74
+ # Raises errors to alert the system if something goes wrong.
58
75
  def reserve_blocks!
59
76
  return unless should_manage_blocks?
60
77
 
@@ -5,8 +5,8 @@ module SpreeCmCommissioner
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- state_machine.before_transition to: :address, do: :hold_blocks!
9
- state_machine.before_transition to: :payment, do: :ensure_blocks_held!
8
+ state_machine.before_transition to: :address, do: :hold_blocks
9
+ state_machine.before_transition to: :payment, do: :ensure_blocks_held
10
10
 
11
11
  state_machine.before_transition to: :complete, do: :request, if: :need_confirmation?
12
12
  state_machine.before_transition to: :complete, do: :generate_bib_number
@@ -1,12 +1,16 @@
1
1
  module SpreeCmCommissioner
2
2
  module Checkout
3
3
  module AdvanceDecorator
4
- # override
4
+ # override to capture seats error only, other errors is fine we can return success with latest order object instead of throw error.
5
+ # seat is special case because we want to return error message.
5
6
  def call(order:)
6
7
  Spree::Dependencies.checkout_next_service.constantize.call(order: order) until cannot_make_transition?(order)
7
- success(order)
8
- rescue StandardError => e
9
- failure(order, e.message)
8
+
9
+ if order.errors[:seats].present?
10
+ failure(order)
11
+ else
12
+ success(order)
13
+ end
10
14
  end
11
15
  end
12
16
  end
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.3.0-pre13'.freeze
2
+ VERSION = '2.3.0-pre16'.freeze
3
3
 
4
4
  module_function
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_cm_commissioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0.pre.pre13
4
+ version: 2.3.0.pre.pre16
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-31 00:00:00.000000000 Z
11
+ date: 2025-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree