spree_cm_commissioner 2.8.2.pre.pre.6 → 2.8.2.pre.pre.7
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/spree/api/v2/tenant/eliminated_contestants_controller.rb +19 -0
- data/app/models/spree_cm_commissioner/show_contestant.rb +0 -5
- data/app/models/spree_cm_commissioner/voting_contestant.rb +1 -1
- data/app/models/spree_cm_commissioner/voting_session.rb +20 -3
- data/app/serializers/spree/v2/tenant/show_contestant_serializer.rb +1 -1
- data/app/serializers/spree/v2/tenant/show_serializer.rb +0 -1
- data/app/serializers/spree/v2/tenant/voting_contestant_serializer.rb +0 -2
- data/app/serializers/spree/v2/tenant/voting_session_serializer.rb +2 -4
- data/app/services/spree_cm_commissioner/api_caches/invalidate.rb +0 -12
- data/app/services/spree_cm_commissioner/voting_contestants/bulk_updater.rb +1 -2
- data/config/routes.rb +1 -1
- data/db/migrate/20260601000000_add_combining_parent_to_cm_voting_sessions.rb +3 -2
- data/lib/spree_cm_commissioner/test_helper/factories/show_factory.rb +0 -16
- data/lib/spree_cm_commissioner/version.rb +1 -1
- metadata +2 -3
- data/app/controllers/spree/api/v2/tenant/show_elimination_sessions_controller.rb +0 -57
- data/db/migrate/20260527062005_add_eliminated_at_to_cm_show_contestants.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 591df0d5df4917d190e645eebdee72c980e9ea67c21467693ed78d1ee6ff28b7
|
|
4
|
+
data.tar.gz: b1d462674dd6e670d2563d6da3c95ca84ae04ed72afdbf3d7a6c26ba79d57296
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a1ff6848bdc1550e7265210e7983a1542f13ed6675968e12d6b84b6878b8bf50af2d177de9af3f4392e616ad17db43d4bc318abf380dd50afa08140554b7471
|
|
7
|
+
data.tar.gz: 2b26975401c635204547177d0853b01a699e304fc23ac5d3e6820d8af58024e2f0e31e3864c0227d38f7992d5deba1a35647e8f3f66f2a9b4d6b27fe4f99c6c9
|
data/Gemfile.lock
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Tenant
|
|
5
|
+
class EliminatedContestantsController < ShowContestantsController
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
def scope
|
|
9
|
+
super.eliminated
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def collection_serializer
|
|
13
|
+
Spree::V2::Tenant::ShowContestantSerializer
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -29,11 +29,6 @@ module SpreeCmCommissioner
|
|
|
29
29
|
|
|
30
30
|
scope :ordered, -> { order(:position, :id) }
|
|
31
31
|
|
|
32
|
-
def eliminate
|
|
33
|
-
self.status = :eliminated
|
|
34
|
-
self.eliminated_at = Time.current
|
|
35
|
-
end
|
|
36
|
-
|
|
37
32
|
self.whitelisted_ransackable_attributes = %w[name contestant_number status gender category origin]
|
|
38
33
|
end
|
|
39
34
|
end
|
|
@@ -32,7 +32,7 @@ module SpreeCmCommissioner
|
|
|
32
32
|
# | 1 | 2 | 1 | ✓ OK | Different session |
|
|
33
33
|
validates :vote_number, uniqueness: { scope: %i[show_contestant_id voting_session_id], allow_nil: true }
|
|
34
34
|
|
|
35
|
-
delegate :name, :contestant_number, :category, :gender,
|
|
35
|
+
delegate :name, :contestant_number, :category, :gender, to: :show_contestant, allow_nil: true
|
|
36
36
|
delegate :can_vote?, to: :voting_session, allow_nil: true
|
|
37
37
|
|
|
38
38
|
def special_rule_type=(value)
|
|
@@ -6,14 +6,12 @@ module SpreeCmCommissioner
|
|
|
6
6
|
belongs_to :vendor, class_name: 'Spree::Vendor', optional: false
|
|
7
7
|
belongs_to :show, class_name: 'SpreeCmCommissioner::Show', optional: false
|
|
8
8
|
belongs_to :episode, class_name: 'Spree::Product', optional: false
|
|
9
|
+
belongs_to :parent, class_name: 'SpreeCmCommissioner::VotingSession', optional: true
|
|
9
10
|
|
|
10
11
|
has_one :season, through: :episode, class_name: 'SpreeCmCommissioner::Show', source: :season
|
|
11
12
|
|
|
12
13
|
has_many :voting_credits, class_name: 'SpreeCmCommissioner::VotingCredit', as: :votable, dependent: :destroy
|
|
13
14
|
has_many :voting_contestants, class_name: 'SpreeCmCommissioner::VotingContestant', dependent: :destroy
|
|
14
|
-
has_many :eliminated_voting_contestants, lambda {
|
|
15
|
-
where(eliminated: true)
|
|
16
|
-
}, class_name: 'SpreeCmCommissioner::VotingContestant', foreign_key: 'voting_session_id'
|
|
17
15
|
has_many :show_contestants, through: :voting_contestants
|
|
18
16
|
has_many :contestants, through: :show, source: :show_contestants
|
|
19
17
|
has_many :votes, class_name: 'SpreeCmCommissioner::Vote', dependent: :destroy
|
|
@@ -30,10 +28,13 @@ module SpreeCmCommissioner
|
|
|
30
28
|
validates :session_key, presence: true, uniqueness: true
|
|
31
29
|
validates :name, :opens_at, :closes_at, :status, presence: true
|
|
32
30
|
validate :closes_after_opens
|
|
31
|
+
validate :closes_at_not_after_parent
|
|
33
32
|
validate :validate_live_stream_url, if: :live_stream_url_changed?
|
|
34
33
|
|
|
35
34
|
before_validation :generate_session_key, on: :create
|
|
36
35
|
before_save :update_live_stream_thumbnail
|
|
36
|
+
after_create :copy_contestants_from_parent, if: -> { pre_vote? && parent.present? }
|
|
37
|
+
after_update :copy_contestants_from_parent, if: -> { pre_vote? && saved_change_to_parent_id? && parent.present? }
|
|
37
38
|
after_update :schedule_counter_reconciliation, if: -> { saved_change_to_status?(from: 'enabled', to: 'closed') }
|
|
38
39
|
# Scopes
|
|
39
40
|
# Uses the database clock (CURRENT_TIMESTAMP) for consistency and to avoid application server clock drift.
|
|
@@ -210,12 +211,28 @@ module SpreeCmCommissioner
|
|
|
210
211
|
self.session_key ||= "#{episode.slug}-#{Time.current.to_i}-#{SecureRandom.hex(8)}"
|
|
211
212
|
end
|
|
212
213
|
|
|
214
|
+
def copy_contestants_from_parent
|
|
215
|
+
parent.voting_contestants.find_each do |vc|
|
|
216
|
+
voting_contestants.find_or_create_by!(show_contestant: vc.show_contestant) do |new_vc|
|
|
217
|
+
new_vc.show_id = show_id
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
213
222
|
def closes_after_opens
|
|
214
223
|
return unless opens_at && closes_at
|
|
215
224
|
|
|
216
225
|
errors.add(:closes_at, 'must be after opens_at') if closes_at <= opens_at
|
|
217
226
|
end
|
|
218
227
|
|
|
228
|
+
def closes_at_not_after_parent
|
|
229
|
+
return unless parent && closes_at && parent.closes_at
|
|
230
|
+
|
|
231
|
+
return unless closes_at > parent.closes_at
|
|
232
|
+
|
|
233
|
+
errors.add(:closes_at, 'cannot be after parent session closes_at')
|
|
234
|
+
end
|
|
235
|
+
|
|
219
236
|
def parse_json_config(value)
|
|
220
237
|
return {} if value.nil? || value == ''
|
|
221
238
|
return value if value.is_a?(Hash)
|
|
@@ -4,7 +4,7 @@ module Spree
|
|
|
4
4
|
class ShowContestantSerializer < BaseSerializer
|
|
5
5
|
set_type :show_contestant
|
|
6
6
|
|
|
7
|
-
attributes :name, :age, :origin, :category, :bio, :gender, :status, :contestant_number, :show_id
|
|
7
|
+
attributes :name, :age, :origin, :category, :bio, :gender, :status, :contestant_number, :show_id
|
|
8
8
|
|
|
9
9
|
attribute :video_highlights do |contestant|
|
|
10
10
|
contestant.video_highlights || []
|
|
@@ -17,7 +17,6 @@ module Spree
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
has_many :voting_sessions, serializer: Spree::V2::Tenant::VotingSessionSerializer
|
|
21
20
|
has_many :episodes, serializer: Spree::V2::Tenant::ShowEpisodeSerializer
|
|
22
21
|
has_many :voting_sessions, serializer: Spree::V2::Tenant::VotingSessionSerializer
|
|
23
22
|
|
|
@@ -12,8 +12,6 @@ module Spree
|
|
|
12
12
|
|
|
13
13
|
attribute :can_vote, &:can_vote?
|
|
14
14
|
|
|
15
|
-
belongs_to :voting_session, serializer: ::Spree::V2::Tenant::VotingSessionSerializer
|
|
16
|
-
|
|
17
15
|
has_many :show_contestant_images, serializer: ::Spree::V2::Tenant::AssetSerializer
|
|
18
16
|
has_many :show_contestant_videos, serializer: ::Spree::V2::Tenant::VideoSerializer
|
|
19
17
|
belongs_to :voting_session, serializer: ::Spree::V2::Tenant::VotingSessionSerializer
|
|
@@ -2,8 +2,8 @@ module Spree
|
|
|
2
2
|
module V2
|
|
3
3
|
module Tenant
|
|
4
4
|
class VotingSessionSerializer < BaseSerializer
|
|
5
|
-
attributes :opens_at, :closes_at, :status, :session_type, :
|
|
6
|
-
:
|
|
5
|
+
attributes :opens_at, :closes_at, :status, :session_type, :live_stream_enabled,
|
|
6
|
+
:live_stream_thumbnail, :live_stream_title, :live_stream_description,
|
|
7
7
|
:position
|
|
8
8
|
|
|
9
9
|
attribute :live_stream_url, &:embedded_live_stream_url
|
|
@@ -11,8 +11,6 @@ module Spree
|
|
|
11
11
|
|
|
12
12
|
belongs_to :episode, serializer: Spree::V2::Tenant::ShowEpisodeSerializer
|
|
13
13
|
belongs_to :show, serializer: Spree::V2::Tenant::ShowSerializer
|
|
14
|
-
|
|
15
|
-
has_many :eliminated_voting_contestants, serializer: ::Spree::V2::Tenant::VotingContestantSerializer
|
|
16
14
|
end
|
|
17
15
|
end
|
|
18
16
|
end
|
|
@@ -66,19 +66,12 @@ module SpreeCmCommissioner
|
|
|
66
66
|
'/api/v2/storefront/homepage_data*'
|
|
67
67
|
],
|
|
68
68
|
'Spree::Taxon' => ['/api/v2/storefront/taxons/:id*'],
|
|
69
|
-
'SpreeCmCommissioner::Show' => ['/api/v2/storefront/taxons/:id*'],
|
|
70
69
|
'Spree::Product' => [
|
|
71
70
|
'/api/v2/tenant/products/:id*',
|
|
72
71
|
'/api/v2/tenant/products/:slug*',
|
|
73
72
|
'/api/v2/storefront/products/:id*',
|
|
74
73
|
'/api/v2/storefront/products/:slug*'
|
|
75
74
|
],
|
|
76
|
-
'SpreeCmCommissioner::ShowEpisode' => [
|
|
77
|
-
'/api/v2/tenant/products/:id*',
|
|
78
|
-
'/api/v2/tenant/products/:slug*',
|
|
79
|
-
'/api/v2/storefront/products/:id*',
|
|
80
|
-
'/api/v2/storefront/products/:slug*'
|
|
81
|
-
],
|
|
82
75
|
'Spree::Vendor' => [
|
|
83
76
|
'/api/v2/tenant/vendors/:id*',
|
|
84
77
|
'/api/v2/storefront/vendors/:id*',
|
|
@@ -94,15 +87,10 @@ module SpreeCmCommissioner
|
|
|
94
87
|
'SpreeCmCommissioner::HomepageBackground' => homepage_background_patterns,
|
|
95
88
|
'Spree::Menu' => ['/api/v2/storefront/menus/*'],
|
|
96
89
|
'Spree::Taxon' => ['/api/v2/storefront/taxons/*'],
|
|
97
|
-
'SpreeCmCommissioner::Show' => ['/api/v2/storefront/taxons/*'],
|
|
98
90
|
'Spree::Product' => [
|
|
99
91
|
'/api/v2/tenant/products/*',
|
|
100
92
|
'/api/v2/storefront/products/*'
|
|
101
93
|
],
|
|
102
|
-
'SpreeCmCommissioner::ShowEpisode' => [
|
|
103
|
-
'/api/v2/tenant/products/*',
|
|
104
|
-
'/api/v2/storefront/products/*'
|
|
105
|
-
],
|
|
106
94
|
'Spree::Vendor' => [
|
|
107
95
|
'/api/v2/tenant/vendors/*',
|
|
108
96
|
'/api/v2/storefront/vendors/*',
|
|
@@ -51,8 +51,7 @@ module SpreeCmCommissioner
|
|
|
51
51
|
return unless attributes.key?(:eliminated)
|
|
52
52
|
return unless attributes[:eliminated]
|
|
53
53
|
|
|
54
|
-
voting_contestant.show_contestant.
|
|
55
|
-
voting_contestant.show_contestant.save!
|
|
54
|
+
voting_contestant.show_contestant.update!(status: :eliminated)
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
# Normalizes raw params into a safe attributes hash.
|
data/config/routes.rb
CHANGED
|
@@ -593,7 +593,7 @@ Spree::Core::Engine.add_routes do
|
|
|
593
593
|
resources :assignments, controller: :show_person_assignments, only: %i[index]
|
|
594
594
|
end
|
|
595
595
|
resources :contestants, controller: :show_contestants, only: %i[show]
|
|
596
|
-
resources :
|
|
596
|
+
resources :eliminated_contestants, controller: :eliminated_contestants, only: %i[index]
|
|
597
597
|
resources :free_vote_claims, only: :create
|
|
598
598
|
end
|
|
599
599
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
class AddCombiningParentToCmVotingSessions < ActiveRecord::Migration[7.0]
|
|
2
2
|
def change
|
|
3
|
-
add_reference :cm_voting_sessions, :
|
|
3
|
+
add_reference :cm_voting_sessions, :parent,
|
|
4
4
|
foreign_key: { to_table: :cm_voting_sessions },
|
|
5
5
|
null: true,
|
|
6
|
-
index: true
|
|
6
|
+
index: true,
|
|
7
|
+
if_not_exists: true
|
|
7
8
|
end
|
|
8
9
|
end
|
|
@@ -100,21 +100,5 @@ FactoryBot.define do
|
|
|
100
100
|
show_contestant { create(:cm_show_contestant, show: show) }
|
|
101
101
|
voting_session { create(:cm_voting_session, episode: create(:cm_show_episode, event: show), show: show, vendor: show.vendor) }
|
|
102
102
|
show_id { show.id }
|
|
103
|
-
eliminated { false }
|
|
104
|
-
|
|
105
|
-
trait :eliminated do
|
|
106
|
-
eliminated { true }
|
|
107
|
-
eliminated_via { :public_vote }
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
trait :eliminated_by_judges do
|
|
111
|
-
eliminated { true }
|
|
112
|
-
eliminated_via { :judges_deadlock }
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
trait :eliminated_by_coach do
|
|
116
|
-
eliminated { true }
|
|
117
|
-
eliminated_via { :coach_decision }
|
|
118
|
-
end
|
|
119
103
|
end
|
|
120
104
|
end
|
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.2.pre.pre.
|
|
4
|
+
version: 2.8.2.pre.pre.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
@@ -1045,6 +1045,7 @@ files:
|
|
|
1045
1045
|
- app/controllers/spree/api/v2/tenant/cms_pages_controller.rb
|
|
1046
1046
|
- app/controllers/spree/api/v2/tenant/customer_notifications_controller.rb
|
|
1047
1047
|
- app/controllers/spree/api/v2/tenant/dynamic_field_options_controller.rb
|
|
1048
|
+
- app/controllers/spree/api/v2/tenant/eliminated_contestants_controller.rb
|
|
1048
1049
|
- app/controllers/spree/api/v2/tenant/free_vote_claims_controller.rb
|
|
1049
1050
|
- app/controllers/spree/api/v2/tenant/guests_controller.rb
|
|
1050
1051
|
- app/controllers/spree/api/v2/tenant/homepage_sections_controller.rb
|
|
@@ -1069,7 +1070,6 @@ files:
|
|
|
1069
1070
|
- app/controllers/spree/api/v2/tenant/routes_controller.rb
|
|
1070
1071
|
- app/controllers/spree/api/v2/tenant/s3_signed_urls_controller.rb
|
|
1071
1072
|
- app/controllers/spree/api/v2/tenant/show_contestants_controller.rb
|
|
1072
|
-
- app/controllers/spree/api/v2/tenant/show_elimination_sessions_controller.rb
|
|
1073
1073
|
- app/controllers/spree/api/v2/tenant/show_people_controller.rb
|
|
1074
1074
|
- app/controllers/spree/api/v2/tenant/show_person_assignments_controller.rb
|
|
1075
1075
|
- app/controllers/spree/api/v2/tenant/shows_controller.rb
|
|
@@ -3276,7 +3276,6 @@ files:
|
|
|
3276
3276
|
- db/migrate/20260520000001_optimize_cm_votes_indexes.rb
|
|
3277
3277
|
- db/migrate/20260525042257_add_vote_number_to_cm_voting_contestants.rb
|
|
3278
3278
|
- db/migrate/20260527035430_add_confirmed_rank_to_cm_voting_contestants.rb
|
|
3279
|
-
- db/migrate/20260527062005_add_eliminated_at_to_cm_show_contestants.rb
|
|
3280
3279
|
- db/migrate/20260529000001_add_session_type_to_cm_voting_sessions.rb
|
|
3281
3280
|
- db/migrate/20260601000000_add_combining_parent_to_cm_voting_sessions.rb
|
|
3282
3281
|
- docker-compose.yml
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module Api
|
|
3
|
-
module V2
|
|
4
|
-
module Tenant
|
|
5
|
-
class ShowEliminationSessionsController < BaseController
|
|
6
|
-
# override
|
|
7
|
-
def collection
|
|
8
|
-
@collection ||= scope
|
|
9
|
-
.includes(
|
|
10
|
-
:episode,
|
|
11
|
-
:show,
|
|
12
|
-
eliminated_voting_contestants: [
|
|
13
|
-
:show_contestant,
|
|
14
|
-
{ show_contestant: %i[show_contestant_images show_contestant_videos] }
|
|
15
|
-
]
|
|
16
|
-
)
|
|
17
|
-
.order('cm_voting_sessions.closes_at DESC')
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# override
|
|
21
|
-
def collection_serializer
|
|
22
|
-
Spree::V2::Tenant::VotingSessionSerializer
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
# override
|
|
28
|
-
def model_class
|
|
29
|
-
SpreeCmCommissioner::VotingSession
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# override
|
|
33
|
-
def scope
|
|
34
|
-
return model_class.none unless current_show
|
|
35
|
-
|
|
36
|
-
current_show.voting_sessions
|
|
37
|
-
.joins(:episode)
|
|
38
|
-
.joins(:voting_contestants)
|
|
39
|
-
.where(voting_contestants: { eliminated: true })
|
|
40
|
-
.distinct
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def current_show
|
|
44
|
-
@current_show ||= show_scope.find_by!(slug: params[:show_id])
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def show_scope
|
|
48
|
-
vendor_ids = @tenant.vendors.select(:id)
|
|
49
|
-
return SpreeCmCommissioner::Show.none if vendor_ids.blank?
|
|
50
|
-
|
|
51
|
-
SpreeCmCommissioner::Show.where(vendor_id: vendor_ids)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|