spree_cm_commissioner 2.5.3 → 2.5.5
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 +4 -4
- data/.env.example +9 -0
- data/Gemfile.lock +1 -1
- data/app/controllers/concerns/spree_cm_commissioner/content_cachable.rb +60 -8
- data/app/controllers/spree/admin/inventory_items_controller.rb +20 -0
- data/app/views/spree/admin/stock_managements/index.html.erb +1 -14
- data/config/routes.rb +1 -0
- data/lib/spree_cm_commissioner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de2ded7a346184d8d61336778882795e5b3129f7057eb9b6626042245f580d0c
|
|
4
|
+
data.tar.gz: e6719bc0d87300189d1c02eca3fc3400985379fdce0c7800c813cbe5d24861ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 44c71677f45daa6d92ec91afa436a7bc88798b6931d9a7a75afc40ad5e7691dd7a7ef8c6b7404bcbe3f1875a2a9d321ad918423dda064716bb208f0b0495aa11
|
|
7
|
+
data.tar.gz: d6bdae499df0757db662bade286df901abf2b3f59d7daecef9140ad8cdf2775a17b35c72159b46f5d813c7ec555b3dc97297b6684f4ddee411e96f74d71961ce
|
data/.env.example
CHANGED
|
@@ -31,3 +31,12 @@ ORGANIZER_URL=http://127.0.0.1:4000/organizer
|
|
|
31
31
|
# Use to sign & verify Distance object:
|
|
32
32
|
# spree_cm_commissioner/distance.rb
|
|
33
33
|
DISTANCE_SIGNING_KEY=hei********************VY
|
|
34
|
+
|
|
35
|
+
# Cache durations (in seconds) for different content types
|
|
36
|
+
# See: app/controllers/concerns/spree_cm_commissioner/content_cachable.rb
|
|
37
|
+
CACHE_CDN_MAX_AGE=86400 # CDN/server-side cache duration for all responses
|
|
38
|
+
CACHE_STATIC_MAX_AGE=86400 # Static content (countries, provinces, seat layouts, CMS pages) - 1 day
|
|
39
|
+
CACHE_SEMI_STATIC_MAX_AGE=3600 # Semi-static content (menus, homepage backgrounds, routes) - 1 hour
|
|
40
|
+
CACHE_MODERATE_MAX_AGE=1800 # Moderate freshness (products, events, vendors) - 30 minutes
|
|
41
|
+
CACHE_REALTIME_MAX_AGE=300 # High freshness (trips, trip search) - 5 minutes
|
|
42
|
+
CACHE_DEFAULT_MAX_AGE=300 # Default for unlisted controllers - 5 minutes
|
data/Gemfile.lock
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Check following file for spec:
|
|
2
|
+
# spec/controllers/application_controller_spec.rb
|
|
1
3
|
module SpreeCmCommissioner
|
|
2
4
|
module ContentCachable
|
|
3
5
|
extend ActiveSupport::Concern
|
|
@@ -6,9 +8,64 @@ module SpreeCmCommissioner
|
|
|
6
8
|
after_action :set_cache_control_for_cdn
|
|
7
9
|
end
|
|
8
10
|
|
|
11
|
+
# Cache duration priorities by content type
|
|
12
|
+
# Priority 1: Static/Rarely Changed (1 day)
|
|
13
|
+
STATIC_CONTENT_CONTROLLERS = %w[
|
|
14
|
+
CountriesController
|
|
15
|
+
ProvincesController
|
|
16
|
+
GuestCardClassesController
|
|
17
|
+
SeatLayoutController
|
|
18
|
+
CmsPagesController
|
|
19
|
+
].freeze
|
|
20
|
+
|
|
21
|
+
# Priority 2: Semi-Static (1 hour)
|
|
22
|
+
SEMI_STATIC_CONTROLLERS = %w[
|
|
23
|
+
MenusController
|
|
24
|
+
HomepageBackgroundController
|
|
25
|
+
HomepageDataController
|
|
26
|
+
PopularRoutesController
|
|
27
|
+
RoutePlacesController
|
|
28
|
+
].freeze
|
|
29
|
+
|
|
30
|
+
# Priority 3: Moderate Freshness (30 minutes)
|
|
31
|
+
MODERATE_FRESHNESS_CONTROLLERS = %w[
|
|
32
|
+
HomepageSectionsController
|
|
33
|
+
TaxonsController
|
|
34
|
+
ProductsController
|
|
35
|
+
EventsController
|
|
36
|
+
EventMatchesController
|
|
37
|
+
AccommodationsController
|
|
38
|
+
VendorsController
|
|
39
|
+
VendorPhotosController
|
|
40
|
+
DynamicFieldsController
|
|
41
|
+
].freeze
|
|
42
|
+
|
|
43
|
+
# Priority 4: High Freshness (5 minutes)
|
|
44
|
+
HIGH_FRESHNESS_CONTROLLERS = %w[
|
|
45
|
+
TripsController
|
|
46
|
+
TripSearchController
|
|
47
|
+
].freeze
|
|
48
|
+
|
|
49
|
+
def shared_max_age
|
|
50
|
+
ENV.fetch('CACHE_CDN_MAX_AGE', 1.day.to_i).to_i
|
|
51
|
+
end
|
|
52
|
+
|
|
9
53
|
# Override This Method based on your UseCase
|
|
10
|
-
|
|
11
|
-
|
|
54
|
+
# Or let it auto-detect based on controller name
|
|
55
|
+
def client_max_age
|
|
56
|
+
controller_name = self.class.name.demodulize
|
|
57
|
+
|
|
58
|
+
if STATIC_CONTENT_CONTROLLERS.include?(controller_name)
|
|
59
|
+
ENV.fetch('CACHE_STATIC_MAX_AGE', 1.day.to_i).to_i
|
|
60
|
+
elsif SEMI_STATIC_CONTROLLERS.include?(controller_name)
|
|
61
|
+
ENV.fetch('CACHE_SEMI_STATIC_MAX_AGE', 1.hour.to_i).to_i
|
|
62
|
+
elsif MODERATE_FRESHNESS_CONTROLLERS.include?(controller_name)
|
|
63
|
+
ENV.fetch('CACHE_MODERATE_MAX_AGE', 30.minutes.to_i).to_i
|
|
64
|
+
elsif HIGH_FRESHNESS_CONTROLLERS.include?(controller_name)
|
|
65
|
+
ENV.fetch('CACHE_REALTIME_MAX_AGE', 5.minutes.to_i).to_i
|
|
66
|
+
else
|
|
67
|
+
ENV.fetch('CACHE_DEFAULT_MAX_AGE', 5.minutes.to_i).to_i
|
|
68
|
+
end
|
|
12
69
|
end
|
|
13
70
|
|
|
14
71
|
def set_cache_control_for_cdn
|
|
@@ -17,12 +74,7 @@ module SpreeCmCommissioner
|
|
|
17
74
|
|
|
18
75
|
# max-age: browser/client cache, s-maxage: CDN/server cache
|
|
19
76
|
# Allow client caching for mobile apps while keeping CDN cache longer
|
|
20
|
-
|
|
21
|
-
response.headers['Cache-Control'] = "public, max-age=#{client_max_age}, s-maxage=#{max_age}"
|
|
22
|
-
|
|
23
|
-
# Pragma: HTTP/1.0 cache directive (predates Cache-Control).
|
|
24
|
-
# 'cache' allows caching.
|
|
25
|
-
response.headers['Pragma'] = 'cache'
|
|
77
|
+
response.headers['Cache-Control'] = "public, max-age=#{client_max_age}, s-maxage=#{shared_max_age}"
|
|
26
78
|
|
|
27
79
|
# Expires: Absolute timestamp when cache becomes stale (HTTP/1.0 fallback)
|
|
28
80
|
response.headers['Expires'] = (Time.zone.now + client_max_age).httpdate
|
|
@@ -58,6 +58,26 @@ module Spree
|
|
|
58
58
|
flash[:success] = "Successfully updated stocks for #{inventory_items.count} items"
|
|
59
59
|
redirect_back fallback_location: admin_product_stock_managements_path(@product)
|
|
60
60
|
end
|
|
61
|
+
|
|
62
|
+
# PATCH /products/:slug/inventory_items/bulk_reset?inventory_ids=1,2,3
|
|
63
|
+
def bulk_reset
|
|
64
|
+
inventory_ids = params[:inventory_ids].to_s.split(',').map(&:to_i)
|
|
65
|
+
inventory_items = @product.inventory_items.where(id: inventory_ids)
|
|
66
|
+
|
|
67
|
+
errors = []
|
|
68
|
+
inventory_items.each do |inventory_item|
|
|
69
|
+
result = SpreeCmCommissioner::Stock::InventoryItemResetter.call(inventory_item: inventory_item)
|
|
70
|
+
errors << result.message unless result.success?
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
if errors.empty?
|
|
74
|
+
flash[:success] = "Successfully reset inventory items (#{inventory_items.count})"
|
|
75
|
+
else
|
|
76
|
+
flash[:error] = errors.join(', ')
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
redirect_back fallback_location: admin_product_stock_managements_path(@product)
|
|
80
|
+
end
|
|
61
81
|
end
|
|
62
82
|
end
|
|
63
83
|
end
|
|
@@ -37,19 +37,6 @@
|
|
|
37
37
|
</div>
|
|
38
38
|
<% end if can?(:update, @product) && can?(:update, variant) %>
|
|
39
39
|
|
|
40
|
-
<% if defined?(@reserved_stocks) %>
|
|
41
|
-
<div>
|
|
42
|
-
<%= svg_icon name: "cart-check.svg", width: '14', height: '14' %>
|
|
43
|
-
<%= label_tag "reserved_stock#{variant.id}", "Reserved Stock: #{@reserved_stocks[variant.id] || 0}", class: "m-0" %>
|
|
44
|
-
<%= link_to_with_icon('capture.svg', "Create Inventory Item", admin_product_inventory_items_path(@product.slug, variant_id: variant.id),
|
|
45
|
-
method: :post,
|
|
46
|
-
remote: false,
|
|
47
|
-
class: 'icon_link btn btn-sm btn-outline-primary ml-2',
|
|
48
|
-
no_text: true
|
|
49
|
-
) unless @inventory_items[variant.id].present? %>
|
|
50
|
-
</div>
|
|
51
|
-
<% end %>
|
|
52
|
-
|
|
53
40
|
<% if variant.permanent_stock? %>
|
|
54
41
|
<div>
|
|
55
42
|
<span type="button" data-toggle="popover" data-trigger="hover" data-placement="right" data-content="This product stock will renew every day">
|
|
@@ -78,7 +65,7 @@
|
|
|
78
65
|
<% end %>
|
|
79
66
|
</span>
|
|
80
67
|
|
|
81
|
-
<%= link_to_with_icon('arrow-counterclockwise.svg', "Reset Inventory Item",
|
|
68
|
+
<%= link_to_with_icon('arrow-counterclockwise.svg', "Reset Inventory Item", bulk_reset_admin_product_inventory_items_path(@product.slug, inventory_item_ids: [inventory_item.id]),
|
|
82
69
|
method: :patch,
|
|
83
70
|
remote: false,
|
|
84
71
|
class: 'icon_link btn btn-sm outline text-dark',
|
data/config/routes.rb
CHANGED
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.5.
|
|
4
|
+
version: 2.5.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|