spree_cm_commissioner 2.8.0.pre.patch1 → 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 517c07235f2ed3444fb68adc3283fb1bc190d1163b7f2957934b90ea312dc2e1
|
|
4
|
+
data.tar.gz: e07b4c9e94dda7c4ace1d65865fe30fdcc2fab8e5f8849af09ed1c124f123437
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8deb858f1bb5153f75fb46f67948abc8410a68b4decda008753f69a15f377e803d93fcb199e9d7dd50b179855ee8c66007d33b219feac7b1c56af7ebfe93a52d
|
|
7
|
+
data.tar.gz: 7d96b7ee72d05c6a25007d52bd6631b50f750bc05f345f6b8846f52dc909b6b8c3c32ddfbadb8c4566ddd175565711a1071fec9e988d8a38d2c05230737852da
|
data/Gemfile.lock
CHANGED
|
@@ -23,6 +23,21 @@ 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
|
+
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
|
|
40
|
+
|
|
26
41
|
def public_quantity_available
|
|
27
42
|
[quantity_available, MAX_DISPLAY_STOCK].min
|
|
28
43
|
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
|