spree_cm_commissioner 2.8.2.pre.pre.7 → 2.8.2.pre.pre.8

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: 591df0d5df4917d190e645eebdee72c980e9ea67c21467693ed78d1ee6ff28b7
4
- data.tar.gz: b1d462674dd6e670d2563d6da3c95ca84ae04ed72afdbf3d7a6c26ba79d57296
3
+ metadata.gz: 5ef384b13b8b23bbd46aa3c9f8f99e8b7b88e9cd78bcf31e44f74534f60b9a8c
4
+ data.tar.gz: 27796cce088d3db3a9ff09332236705ae3430d4f4065b2d3fdede50016987c41
5
5
  SHA512:
6
- metadata.gz: 7a1ff6848bdc1550e7265210e7983a1542f13ed6675968e12d6b84b6878b8bf50af2d177de9af3f4392e616ad17db43d4bc318abf380dd50afa08140554b7471
7
- data.tar.gz: 2b26975401c635204547177d0853b01a699e304fc23ac5d3e6820d8af58024e2f0e31e3864c0227d38f7992d5deba1a35647e8f3f66f2a9b4d6b27fe4f99c6c9
6
+ metadata.gz: 7a565f861ce630f95e7422771a5e2188084ad4f52fe7f62c62d229b63904a1a03496429aa728a02eef5eb21f26a733899dde2d320cd575c0156fa99892900648
7
+ data.tar.gz: bfcd0620eb133c51d7ca6f9c55b72aff078955b7d27dbd96a5f08c9090cc4ea04812e6eb0df086b377789f80405eae142d4e2ffa44a0187cc76dd74f1a1c2999
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.8.2.pre.pre.7)
37
+ spree_cm_commissioner (2.8.2.pre.pre.8)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -0,0 +1,57 @@
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
@@ -29,6 +29,11 @@ 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
+
32
37
  self.whitelisted_ransackable_attributes = %w[name contestant_number status gender category origin]
33
38
  end
34
39
  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, to: :show_contestant, allow_nil: true
35
+ delegate :name, :contestant_number, :category, :gender, :eliminated_at, 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)
@@ -12,6 +12,9 @@ module SpreeCmCommissioner
12
12
 
13
13
  has_many :voting_credits, class_name: 'SpreeCmCommissioner::VotingCredit', as: :votable, dependent: :destroy
14
14
  has_many :voting_contestants, class_name: 'SpreeCmCommissioner::VotingContestant', dependent: :destroy
15
+ has_many :eliminated_voting_contestants, lambda {
16
+ where(eliminated: true)
17
+ }, class_name: 'SpreeCmCommissioner::VotingContestant', foreign_key: 'voting_session_id'
15
18
  has_many :show_contestants, through: :voting_contestants
16
19
  has_many :contestants, through: :show, source: :show_contestants
17
20
  has_many :votes, class_name: 'SpreeCmCommissioner::Vote', dependent: :destroy
@@ -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, :eliminated_at
8
8
 
9
9
  attribute :video_highlights do |contestant|
10
10
  contestant.video_highlights || []
@@ -17,6 +17,7 @@ module Spree
17
17
  end
18
18
  end
19
19
 
20
+ has_many :voting_sessions, serializer: Spree::V2::Tenant::VotingSessionSerializer
20
21
  has_many :episodes, serializer: Spree::V2::Tenant::ShowEpisodeSerializer
21
22
  has_many :voting_sessions, serializer: Spree::V2::Tenant::VotingSessionSerializer
22
23
 
@@ -12,6 +12,8 @@ module Spree
12
12
 
13
13
  attribute :can_vote, &:can_vote?
14
14
 
15
+ belongs_to :voting_session, serializer: ::Spree::V2::Tenant::VotingSessionSerializer
16
+
15
17
  has_many :show_contestant_images, serializer: ::Spree::V2::Tenant::AssetSerializer
16
18
  has_many :show_contestant_videos, serializer: ::Spree::V2::Tenant::VideoSerializer
17
19
  belongs_to :voting_session, serializer: ::Spree::V2::Tenant::VotingSessionSerializer
@@ -11,6 +11,8 @@ 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
14
16
  end
15
17
  end
16
18
  end
@@ -66,12 +66,19 @@ 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*'],
69
70
  'Spree::Product' => [
70
71
  '/api/v2/tenant/products/:id*',
71
72
  '/api/v2/tenant/products/:slug*',
72
73
  '/api/v2/storefront/products/:id*',
73
74
  '/api/v2/storefront/products/:slug*'
74
75
  ],
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
+ ],
75
82
  'Spree::Vendor' => [
76
83
  '/api/v2/tenant/vendors/:id*',
77
84
  '/api/v2/storefront/vendors/:id*',
@@ -87,10 +94,15 @@ module SpreeCmCommissioner
87
94
  'SpreeCmCommissioner::HomepageBackground' => homepage_background_patterns,
88
95
  'Spree::Menu' => ['/api/v2/storefront/menus/*'],
89
96
  'Spree::Taxon' => ['/api/v2/storefront/taxons/*'],
97
+ 'SpreeCmCommissioner::Show' => ['/api/v2/storefront/taxons/*'],
90
98
  'Spree::Product' => [
91
99
  '/api/v2/tenant/products/*',
92
100
  '/api/v2/storefront/products/*'
93
101
  ],
102
+ 'SpreeCmCommissioner::ShowEpisode' => [
103
+ '/api/v2/tenant/products/*',
104
+ '/api/v2/storefront/products/*'
105
+ ],
94
106
  'Spree::Vendor' => [
95
107
  '/api/v2/tenant/vendors/*',
96
108
  '/api/v2/storefront/vendors/*',
@@ -51,7 +51,8 @@ module SpreeCmCommissioner
51
51
  return unless attributes.key?(:eliminated)
52
52
  return unless attributes[:eliminated]
53
53
 
54
- voting_contestant.show_contestant.update!(status: :eliminated)
54
+ voting_contestant.show_contestant.eliminate
55
+ voting_contestant.show_contestant.save!
55
56
  end
56
57
 
57
58
  # 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 :eliminated_contestants, controller: :eliminated_contestants, only: %i[index]
596
+ resources :elimination_sessions, controller: :show_elimination_sessions, only: %i[index]
597
597
  resources :free_vote_claims, only: :create
598
598
  end
599
599
 
@@ -0,0 +1,5 @@
1
+ class AddEliminatedAtToCmShowContestants < ActiveRecord::Migration[7.0]
2
+ def change
3
+ add_column :cm_show_contestants, :eliminated_at, :datetime, default: nil
4
+ end
5
+ end
@@ -100,5 +100,21 @@ 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
103
119
  end
104
120
  end
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.8.2.pre.pre.7'.freeze
2
+ VERSION = '2.8.2.pre.pre.8'.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.2.pre.pre.7
4
+ version: 2.8.2.pre.pre.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
@@ -1045,7 +1045,6 @@ 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
1049
1048
  - app/controllers/spree/api/v2/tenant/free_vote_claims_controller.rb
1050
1049
  - app/controllers/spree/api/v2/tenant/guests_controller.rb
1051
1050
  - app/controllers/spree/api/v2/tenant/homepage_sections_controller.rb
@@ -1070,6 +1069,7 @@ files:
1070
1069
  - app/controllers/spree/api/v2/tenant/routes_controller.rb
1071
1070
  - app/controllers/spree/api/v2/tenant/s3_signed_urls_controller.rb
1072
1071
  - 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,6 +3276,7 @@ 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
3279
3280
  - db/migrate/20260529000001_add_session_type_to_cm_voting_sessions.rb
3280
3281
  - db/migrate/20260601000000_add_combining_parent_to_cm_voting_sessions.rb
3281
3282
  - docker-compose.yml
@@ -1,19 +0,0 @@
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