spree_cm_commissioner 2.7.1.pre.pre9 → 2.8.0.pre.patch1

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: 185d0800fe2226d15f68f7bac984f9c4ba88b084a3669351f8cde12154b12707
4
- data.tar.gz: 6d9ca32ab0abf773108964da4955281cb88c9490c671c8ddb36056343d2db8a4
3
+ metadata.gz: 624d077988823212d28d3809a7fb549cea92fd6f057f92d160d3eac8acfd6af5
4
+ data.tar.gz: 19203d0d9a970fc41900bf4cb2c37c9c6441f3c08a9445300d4f76d5fbf3a6bd
5
5
  SHA512:
6
- metadata.gz: 5826bd3e8bcc01930818656e09b6ed5b2358d369f1a6bbbe89f0d6365889fd033db7e3a176fbbfda075d59460d5e23c2bc34450c20aec0477e6ce614ae21a3cc
7
- data.tar.gz: 251e572fe4b88c535c90a3b87b21a557a07e232eed3551dd8679d16f14cbd8d0e517f2a8c3c1e1b0a34f4fdeff0db4570df9b6990d5eb9305c27add3d85deee1
6
+ metadata.gz: 62f6d0064ceb620aa87db423ffcfba07d7cbdd15e9184174562fdb4c4ba4e0a563830f5f4dfbfc5ad70f623af48a0f8e2948111ff4cc429605d7ddaa1c7c8f47
7
+ data.tar.gz: 736b84fb19babcba6a9e25074c8616cb4a12921f758e00c4d7c683b9550117a014543e75d47c8e8b83a50268bc83e71228d7aad04d0f24da7736f8b5ae0fa169
data/.env.example CHANGED
@@ -34,6 +34,7 @@ DISTANCE_SIGNING_KEY=hei********************VY
34
34
 
35
35
  # Cache durations (in seconds) for different content types
36
36
  # See: app/controllers/concerns/spree_cm_commissioner/content_cachable.rb
37
+ CACHE_AUTO_INVALIDATION_DISABLED="" # Set to yes to disable CDN cache invalidation entirely (kill switch)
37
38
  CACHE_CDN_MAX_AGE=86400 # CDN/server-side cache duration for all responses
38
39
  CACHE_STATIC_MAX_AGE=86400 # Static content (countries, provinces, seat layouts, CMS pages) - 1 day
39
40
  CACHE_SEMI_STATIC_MAX_AGE=3600 # Semi-static content (menus, homepage backgrounds, routes) - 1 hour
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.7.1.pre.pre9)
37
+ spree_cm_commissioner (2.8.0.pre.patch1)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -10,6 +10,7 @@
10
10
  # Supported types:
11
11
  # - boolean
12
12
  # - string
13
+ # - text
13
14
  # - integer
14
15
  # - array
15
16
  # - datetime
@@ -105,7 +106,7 @@ module SpreeCmCommissioner
105
106
  ActiveModel::Type::Boolean.new.cast(raw_value)
106
107
  when :integer
107
108
  raw_value.to_i
108
- when :string
109
+ when :string, :text
109
110
  raw_value.to_s
110
111
  when :array
111
112
  Array(raw_value)
@@ -136,6 +137,14 @@ module SpreeCmCommissioner
136
137
  end
137
138
  when :string
138
139
  validates key, length: { maximum: 255 }, allow_nil: true
140
+ when :text
141
+ validate do
142
+ metadata = send(column_name) || {}
143
+ raw_value = metadata[key.to_s]
144
+ next if raw_value.nil?
145
+
146
+ errors.add(key, 'must be a string') unless raw_value.is_a?(String)
147
+ end
139
148
  when :array
140
149
  validate do
141
150
  metadata = send(column_name) || {}
@@ -23,9 +23,6 @@ module SpreeCmCommissioner
23
23
 
24
24
  before_save -> { self.product_type = variant.product_type }, if: -> { product_type.nil? }
25
25
 
26
- # Create maintaining task to purge product related caches
27
- after_commit { SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation.pending.create_or_find_by(maintainable: variant.product) }
28
-
29
26
  def public_quantity_available
30
27
  [quantity_available, MAX_DISPLAY_STOCK].min
31
28
  end
@@ -3,6 +3,8 @@ module SpreeCmCommissioner
3
3
  module MaintenanceTasks
4
4
  class CacheInvalidation < MaintenanceTask
5
5
  def maintain
6
+ return if ENV['CACHE_AUTO_INVALIDATION_DISABLED'] == 'yes'
7
+
6
8
  if maintainable.is_a?(SpreeCmCommissioner::HomepageBackground) || maintainable.is_a?(Spree::Menu)
7
9
  SpreeCmCommissioner::HomepageDataLoader.clear_cache
8
10
  end
@@ -1,6 +1,7 @@
1
1
  module SpreeCmCommissioner
2
2
  class Route < Base
3
3
  include SpreeCmCommissioner::RouteType
4
+ include SpreeCmCommissioner::StoreMetadata
4
5
 
5
6
  belongs_to :vendor, class_name: 'Spree::Vendor', optional: false
6
7
  belongs_to :tenant, class_name: 'SpreeCmCommissioner::Tenant', optional: true
@@ -29,6 +30,8 @@ module SpreeCmCommissioner
29
30
 
30
31
  delegate :multi_leg?, to: :route_stops
31
32
 
33
+ store_public_metadata :terms_and_conditions, :text
34
+
32
35
  def prices_for(currency)
33
36
  route_prices.for_currency(currency)
34
37
  end
@@ -8,7 +8,20 @@ module SpreeCmCommissioner
8
8
  base.after_commit :adjust_inventory_items_async, on: :destroy
9
9
 
10
10
  # Create maintaining task to purge product related caches
11
- base.after_commit { SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation.pending.create_or_find_by(maintainable: variant.product) }
11
+ base.after_commit :schedule_product_cache_invalidation
12
+ end
13
+
14
+ def schedule_product_cache_invalidation
15
+ return unless saved_change_to_count_on_hand?
16
+
17
+ # Only invalidate when transitioning between in-stock and out-of-stock:
18
+ # - out-of-stock → in-stock (0 → N): invalidate
19
+ # - in-stock → out-of-stock (N → 0): invalidate
20
+ # - non-zero to non-zero (5 → 3): skip — cached in_stock value is unchanged
21
+ old_val, new_val = saved_change_to_count_on_hand
22
+ return if old_val.to_i.positive? && new_val.to_i.positive?
23
+
24
+ SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation.pending.create_or_find_by(maintainable: variant.product)
12
25
  end
13
26
 
14
27
  def update_vendor_total_inventory
@@ -100,6 +100,7 @@ module Spree
100
100
  vendor_id
101
101
  route_type
102
102
  route_stops
103
+ terms_and_conditions
103
104
  ]
104
105
  end
105
106
  end
@@ -0,0 +1,6 @@
1
+ class AddPublicAndPrivateMetadataToCmRoutes < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :cm_routes, :public_metadata, :jsonb, default: {}, if_not_exists: true
4
+ add_column :cm_routes, :private_metadata, :jsonb, default: {}, if_not_exists: true
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.7.1-pre9'.freeze
2
+ VERSION = '2.8.0-patch1'.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.7.1.pre.pre9
4
+ version: 2.8.0.pre.patch1
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-07 00:00:00.000000000 Z
11
+ date: 2026-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree
@@ -3159,6 +3159,7 @@ files:
3159
3159
  - db/migrate/20260330032108_add_vendor_id_to_spree_taxonomies.rb
3160
3160
  - db/migrate/20260401080000_create_cm_route_prices.rb
3161
3161
  - db/migrate/20260410080000_add_payment_locked_at_to_cm_reserved_blocks.rb
3162
+ - db/migrate/20260504100000_add_public_and_private_metadata_to_cm_routes.rb
3162
3163
  - db/migrate/20260506090000_remove_default_from_cm_guests_nationality_group.rb
3163
3164
  - docker-compose.yml
3164
3165
  - docs/api/scoped-access-token-endpoints.md