spree_cm_commissioner 2.7.1.pre.pre9 → 2.8.0.pre.patch2

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: 517c07235f2ed3444fb68adc3283fb1bc190d1163b7f2957934b90ea312dc2e1
4
+ data.tar.gz: e07b4c9e94dda7c4ace1d65865fe30fdcc2fab8e5f8849af09ed1c124f123437
5
5
  SHA512:
6
- metadata.gz: 5826bd3e8bcc01930818656e09b6ed5b2358d369f1a6bbbe89f0d6365889fd033db7e3a176fbbfda075d59460d5e23c2bc34450c20aec0477e6ce614ae21a3cc
7
- data.tar.gz: 251e572fe4b88c535c90a3b87b21a557a07e232eed3551dd8679d16f14cbd8d0e517f2a8c3c1e1b0a34f4fdeff0db4570df9b6990d5eb9305c27add3d85deee1
6
+ metadata.gz: 8deb858f1bb5153f75fb46f67948abc8410a68b4decda008753f69a15f377e803d93fcb199e9d7dd50b179855ee8c66007d33b219feac7b1c56af7ebfe93a52d
7
+ data.tar.gz: 7d96b7ee72d05c6a25007d52bd6631b50f750bc05f345f6b8846f52dc909b6b8c3c32ddfbadb8c4566ddd175565711a1071fec9e988d8a38d2c05230737852da
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.patch2)
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,8 +23,20 @@ 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) }
26
+ after_commit :schedule_product_cache_invalidation
27
+
28
+ def schedule_product_cache_invalidation
29
+ return unless saved_change_to_quantity_available?
30
+
31
+ # Only invalidate when transitioning between in-stock and out-of-stock:
32
+ # - out-of-stock → in-stock (0 → N): invalidate
33
+ # - in-stock → out-of-stock (N → 0): invalidate
34
+ # - non-zero to non-zero (5 → 3): skip — cached in_stock value is unchanged
35
+ old_val, new_val = saved_change_to_quantity_available
36
+ return if old_val.to_i.positive? && new_val.to_i.positive?
37
+
38
+ SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation.pending.create_or_find_by(maintainable: variant.product)
39
+ end
28
40
 
29
41
  def public_quantity_available
30
42
  [quantity_available, MAX_DISPLAY_STOCK].min
@@ -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
@@ -6,9 +6,6 @@ module SpreeCmCommissioner
6
6
 
7
7
  base.after_commit :create_inventory_items, on: :create
8
8
  base.after_commit :adjust_inventory_items_async, on: :destroy
9
-
10
- # Create maintaining task to purge product related caches
11
- base.after_commit { SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation.pending.create_or_find_by(maintainable: variant.product) }
12
9
  end
13
10
 
14
11
  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-patch2'.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.patch2
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