spree_cm_commissioner 2.5.13.pre.patch1 → 2.5.13.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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/concerns/spree_cm_commissioner/content_cachable.rb +1 -1
- data/app/controllers/spree/api/v2/operator/guest_json_gzips_controller.rb +9 -0
- data/app/helpers/spree/base_helper_decorator.rb +1 -1
- data/app/models/spree_cm_commissioner/line_item_decorator.rb +4 -0
- data/app/services/spree_cm_commissioner/integrations/base/sync_result.rb +23 -1
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/polling/sync_matches.rb +2 -2
- data/app/services/spree_cm_commissioner/integrations/stadium_x_v1/polling/sync_zones.rb +18 -8
- 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: 93df32aae4991bb798b86f21c7ddfc3b71e13fc6c5a71ce4315a50eaa70ea1e6
|
|
4
|
+
data.tar.gz: 37574b773bbfc43008b28d390de0a032e9ab5db9d08d0307b10de20075fabcfe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17d233c16e34ee73284559a5536ba042c955a1a140d45cc172645d91cf4bbda83a7025a99886a5bd61ead85d16696c75af8c3db015aba9e5b6b2bc12ca25e489
|
|
7
|
+
data.tar.gz: 64ffb26a7ad38915f38d655878eba9521b4791cdbab6d6a51d558d81a4f3a3a112fad0063ad413f858b1d9997e750f3b62abc1deccf3da704d429560ef7ced69
|
data/Gemfile.lock
CHANGED
|
@@ -64,7 +64,7 @@ module SpreeCmCommissioner
|
|
|
64
64
|
elsif HIGH_FRESHNESS_CONTROLLERS.include?(controller_name)
|
|
65
65
|
ENV.fetch('CACHE_REALTIME_MAX_AGE', 5.minutes.to_i).to_i
|
|
66
66
|
else
|
|
67
|
-
ENV.fetch('CACHE_DEFAULT_MAX_AGE',
|
|
67
|
+
ENV.fetch('CACHE_DEFAULT_MAX_AGE', 0.minutes.to_i).to_i
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -8,6 +8,15 @@ module Spree
|
|
|
8
8
|
before_action :require_spree_current_user
|
|
9
9
|
before_action :require_event_user
|
|
10
10
|
|
|
11
|
+
# Override index to disable server-side caching.
|
|
12
|
+
# We always want to show the latest exports and their download status.
|
|
13
|
+
# The app will cache files on its side to avoid unnecessary server requests once files are ready.
|
|
14
|
+
def index
|
|
15
|
+
render_serialized_payload do
|
|
16
|
+
serialize_collection(paginated_collection)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
11
20
|
# POST /api/v2/operator/guest_json_gzips
|
|
12
21
|
# - taxon_id=1
|
|
13
22
|
# - resource_includes[]=[check_ins,check_ins.check_in_by]
|
|
@@ -106,7 +106,7 @@ module SpreeCmCommissioner::Integrations::Base
|
|
|
106
106
|
#
|
|
107
107
|
# @param record [Object] The record to save (defaults to the tracked record)
|
|
108
108
|
def save_if_changed!(record = @record)
|
|
109
|
-
return unless record.new_record? || record.changed?
|
|
109
|
+
return unless record.new_record? || record.changed? || default_price_changed?(record)
|
|
110
110
|
|
|
111
111
|
record.save!
|
|
112
112
|
|
|
@@ -117,6 +117,28 @@ module SpreeCmCommissioner::Integrations::Base
|
|
|
117
117
|
@sync_result.increment_metric(@type, :updated)
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
|
+
|
|
121
|
+
private
|
|
122
|
+
|
|
123
|
+
# Check if record's default_price has changed (for Spree variants/products)
|
|
124
|
+
def default_price_changed?(record)
|
|
125
|
+
variant_price_changed?(record) || product_price_changed?(record)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def variant_price_changed?(record)
|
|
129
|
+
price = record.try(:default_price)
|
|
130
|
+
price_changed?(price)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def product_price_changed?(record)
|
|
134
|
+
master = record.try(:master)
|
|
135
|
+
price = master&.default_price
|
|
136
|
+
price_changed?(price)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def price_changed?(price)
|
|
140
|
+
price.present? && (price.changed? || price.new_record?)
|
|
141
|
+
end
|
|
120
142
|
end
|
|
121
143
|
|
|
122
144
|
# Increment a metric counter
|
|
@@ -36,8 +36,8 @@ class SpreeCmCommissioner::Integrations::StadiumXV1
|
|
|
36
36
|
|
|
37
37
|
match_mapping = Spree::Taxon.find_or_initialize_integration_mapping(integration_id: @integration.id, external_id: external_match._id)
|
|
38
38
|
match_taxon = match_mapping.internal
|
|
39
|
-
match_name = "#{external_match.home_name} vs #{external_match.away_name}"
|
|
40
|
-
match_permalink = generate_match_permalink(match_name)
|
|
39
|
+
match_name = "#{external_match.home_name} vs #{external_match.away_name} - #{external_match.date} #{external_match.time}"
|
|
40
|
+
match_permalink = match_taxon.persisted? ? match_taxon.permalink : generate_match_permalink(match_name)
|
|
41
41
|
|
|
42
42
|
# Track match sync and create event taxon directly under events/
|
|
43
43
|
@sync_result.track(:match, match_taxon) do |tracker|
|
|
@@ -13,12 +13,14 @@ class SpreeCmCommissioner::Integrations::StadiumXV1
|
|
|
13
13
|
match_mapping = Spree::Taxon.find_integration_mapping(integration_id: @integration.id, external_id: external_match_id)
|
|
14
14
|
raise SpreeCmCommissioner::Integrations::SyncError, "Match not found: #{external_match_id}" if match_mapping.blank?
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
match_section = match_mapping.internal.children.first_or_create! { |s| s.name = 'Zones' }
|
|
17
|
+
|
|
18
|
+
synced_zone_mappings = sync_zones!(match_mapping, match_section)
|
|
19
|
+
cleanup_stale_mappings!(match_mapping, synced_zone_mappings, match_section)
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
# Sync zones for a specific club and match
|
|
21
|
-
def sync_zones!(match_mapping)
|
|
23
|
+
def sync_zones!(match_mapping, match_section)
|
|
22
24
|
external_club_id = match_mapping.external_payload&.dig('club_id')
|
|
23
25
|
raise SpreeCmCommissioner::Integrations::SyncError, 'club_id is required' if external_club_id.blank?
|
|
24
26
|
|
|
@@ -35,9 +37,8 @@ class SpreeCmCommissioner::Integrations::StadiumXV1
|
|
|
35
37
|
zone.set_match_id(match_mapping.external_id)
|
|
36
38
|
end
|
|
37
39
|
|
|
38
|
-
taxon_match_section = match_mapping.internal.children.first_or_create! { |s| s.name = 'Zones' }
|
|
39
40
|
synced_zone_mappings = external_zones.map do |external_zone|
|
|
40
|
-
sync_zone!(external_zone, match_mapping.internal,
|
|
41
|
+
sync_zone!(external_zone, match_mapping.internal, match_section)
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
CmAppLogger.log(
|
|
@@ -50,7 +51,7 @@ class SpreeCmCommissioner::Integrations::StadiumXV1
|
|
|
50
51
|
|
|
51
52
|
private
|
|
52
53
|
|
|
53
|
-
def sync_zone!(external_zone, internal_match,
|
|
54
|
+
def sync_zone!(external_zone, internal_match, match_section)
|
|
54
55
|
Spree::Product.transaction do
|
|
55
56
|
product_mapping = Spree::Product.find_or_initialize_integration_mapping(integration_id: @integration.id, external_id: external_zone._id)
|
|
56
57
|
product = product_mapping.internal
|
|
@@ -66,7 +67,7 @@ class SpreeCmCommissioner::Integrations::StadiumXV1
|
|
|
66
67
|
vendor: @integration.vendor,
|
|
67
68
|
product_type: :ecommerce,
|
|
68
69
|
event: internal_match,
|
|
69
|
-
taxons: [
|
|
70
|
+
taxons: [match_section],
|
|
70
71
|
name: external_zone.title.strip,
|
|
71
72
|
price: external_zone.online_price,
|
|
72
73
|
available_on: external_zone.start_datetime,
|
|
@@ -78,6 +79,9 @@ class SpreeCmCommissioner::Integrations::StadiumXV1
|
|
|
78
79
|
tracker.save_if_changed!(product)
|
|
79
80
|
end
|
|
80
81
|
|
|
82
|
+
classification = product.classifications.find_by(taxon_id: match_section.id)
|
|
83
|
+
classification&.update!(visible: true)
|
|
84
|
+
|
|
81
85
|
product_mapping.mark_as_active!(external_payload: external_zone.to_h)
|
|
82
86
|
|
|
83
87
|
ensure_variant_with_zone_option_value!(product, external_zone, zone_option_type, color_option_type)
|
|
@@ -190,7 +194,7 @@ class SpreeCmCommissioner::Integrations::StadiumXV1
|
|
|
190
194
|
# Archive stale zone mappings that are no longer in the external API
|
|
191
195
|
# Finds all active zone mappings for this integration and archives any
|
|
192
196
|
# that weren't included in the latest API response.
|
|
193
|
-
def cleanup_stale_mappings!(match_mapping, synced_zone_mappings)
|
|
197
|
+
def cleanup_stale_mappings!(match_mapping, synced_zone_mappings, match_section)
|
|
194
198
|
synced_external_zone_ids = synced_zone_mappings.map(&:external_id)
|
|
195
199
|
|
|
196
200
|
# Find all active zone mappings for this integration and match
|
|
@@ -207,6 +211,12 @@ class SpreeCmCommissioner::Integrations::StadiumXV1
|
|
|
207
211
|
mapping.internal.discontinue!
|
|
208
212
|
|
|
209
213
|
mapping.mark_as_archived!
|
|
214
|
+
classification = Spree::Classification.find_or_initialize_by(
|
|
215
|
+
product_id: mapping.internal_id,
|
|
216
|
+
taxon_id: match_section.id
|
|
217
|
+
)
|
|
218
|
+
classification.update!(visible: false)
|
|
219
|
+
|
|
210
220
|
@sync_result.increment_metric(:zone, :discontinued)
|
|
211
221
|
end
|
|
212
222
|
end
|
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.13.pre.
|
|
4
|
+
version: 2.5.13.pre.patch3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|