spree_cm_commissioner 2.8.0.pre.patch1 → 2.8.0.pre.patch3

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: 624d077988823212d28d3809a7fb549cea92fd6f057f92d160d3eac8acfd6af5
4
- data.tar.gz: 19203d0d9a970fc41900bf4cb2c37c9c6441f3c08a9445300d4f76d5fbf3a6bd
3
+ metadata.gz: 76637432e996b37ca03c838a76d393a144f0496c364591be35b7fee69d4020c3
4
+ data.tar.gz: 20fc8d9b5889475f5b11826d59380c13a8ef414f2006befa6a4d0bb7fd6395a8
5
5
  SHA512:
6
- metadata.gz: 62f6d0064ceb620aa87db423ffcfba07d7cbdd15e9184174562fdb4c4ba4e0a563830f5f4dfbfc5ad70f623af48a0f8e2948111ff4cc429605d7ddaa1c7c8f47
7
- data.tar.gz: 736b84fb19babcba6a9e25074c8616cb4a12921f758e00c4d7c683b9550117a014543e75d47c8e8b83a50268bc83e71228d7aad04d0f24da7736f8b5ae0fa169
6
+ metadata.gz: 1226aa03736bc82f722c9a8c2c32bafb2edfeae4dff4677fedcab0e3b3d617b01b81552d67dcb3bade8b3c8ded515cd9c1de7d7e8e4ac74dbc7deb556af01f25
7
+ data.tar.gz: e06a1fe22fa97440e84bcf331ffb57aa3cb163a9e5bebb369d38fa0796aa51ff43a143369bada379fa9d9f38e5b61c2a37d7e5e102666eb1cf84b96a45310520
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.8.0.pre.patch1)
37
+ spree_cm_commissioner (2.8.0.pre.patch3)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -23,6 +23,24 @@ module SpreeCmCommissioner
23
23
 
24
24
  before_save -> { self.product_type = variant.product_type }, if: -> { product_type.nil? }
25
25
 
26
+ after_commit :schedule_product_cache_invalidation
27
+
28
+ # Only for ecommerce: the app uses product.in_stock? (derived from quantity_available) for product cards.
29
+ # Other types (e.g. accommodation, bus) have many inventory items (including daily-generated ones),
30
+ # so invalidating per item would flood the task queue.
31
+ #
32
+ # This is temporary until we have a more robust cache invalidation strategy in place.
33
+ def schedule_product_cache_invalidation
34
+ return unless ecommerce?
35
+ return unless saved_change_to_quantity_available?
36
+
37
+ # Only fires on in_stock status transition (0 ↔ N); non-zero to non-zero changes are skipped.
38
+ old_val, new_val = saved_change_to_quantity_available
39
+ return if old_val.to_i.positive? && new_val.to_i.positive?
40
+
41
+ SpreeCmCommissioner::MaintenanceTasks::CacheInvalidation.pending.create_or_find_by(maintainable: variant.product)
42
+ end
43
+
26
44
  def public_quantity_available
27
45
  [quantity_available, MAX_DISPLAY_STOCK].min
28
46
  end
@@ -6,22 +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 :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)
25
9
  end
26
10
 
27
11
  def update_vendor_total_inventory
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.8.0-patch1'.freeze
2
+ VERSION = '2.8.0-patch3'.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.0.pre.patch1
4
+ version: 2.8.0.pre.patch3
5
5
  platform: ruby
6
6
  authors:
7
7
  - You