Skip to content

Commit 60f03c3

Browse files
committed
fix: adjust draft plans serializer
1 parent 1549ad1 commit 60f03c3

2 files changed

Lines changed: 35 additions & 35 deletions

File tree

app/controllers/api/v1/strategy/draft_plans_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def index
1717
result = paginate(plans)
1818

1919
render_success({
20-
draft_plans: Strategy::Serializers::DraftPlanSerializer.render_as_hash(result[:data]),
20+
draft_plans: ::Strategy::Serializers::DraftPlanSerializer.render_as_hash(result[:data]),
2121
total: result[:pagination][:total_count],
2222
page: result[:pagination][:current_page],
2323
per_page: result[:pagination][:per_page],
@@ -28,7 +28,7 @@ def index
2828
# GET /api/v1/strategy/draft_plans/:id
2929
def show
3030
render_success({
31-
draft_plan: Strategy::Serializers::DraftPlanSerializer.render_as_hash(@draft_plan)
31+
draft_plan: ::Strategy::Serializers::DraftPlanSerializer.render_as_hash(@draft_plan)
3232
})
3333
end
3434

@@ -48,7 +48,7 @@ def create
4848
)
4949

5050
render_created({
51-
draft_plan: Strategy::Serializers::DraftPlanSerializer.render_as_hash(plan)
51+
draft_plan: ::Strategy::Serializers::DraftPlanSerializer.render_as_hash(plan)
5252
}, message: 'Draft plan created successfully')
5353
else
5454
render_error(
@@ -75,7 +75,7 @@ def update
7575
)
7676

7777
render_updated({
78-
draft_plan: Strategy::Serializers::DraftPlanSerializer.render_as_hash(@draft_plan)
78+
draft_plan: ::Strategy::Serializers::DraftPlanSerializer.render_as_hash(@draft_plan)
7979
})
8080
else
8181
render_error(

app/models/draft_plan.rb

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,37 @@ def activate!
111111
update!(is_active: true)
112112
end
113113

114+
# Check if we have priority picks for all roles
115+
def blind_pick_ready?
116+
Constants::Player::ROLES.all? { |role| priority_picks&.key?(role) }
117+
end
118+
119+
# Calculate what percentage of possible scenarios are covered
120+
def scenario_coverage
121+
return 0 if total_scenarios.zero?
122+
123+
# Simplified coverage calculation
124+
# In a real scenario, this would analyze ban combinations
125+
[((total_scenarios / 10.0) * 100).round(2), 100].min
126+
end
127+
128+
# Check how many opponent comfort picks are banned
129+
def comfort_picks_coverage
130+
comfort = opponent_comfort_picks
131+
return 100 if comfort.empty?
132+
133+
banned = (our_bans & comfort).size
134+
((banned.to_f / comfort.size) * 100).round(2)
135+
end
136+
137+
# Suggest additional bans based on opponent comfort picks
138+
def suggest_bans
139+
comfort = opponent_comfort_picks
140+
already_banned = our_bans || []
141+
142+
(comfort - already_banned).first(5)
143+
end
144+
114145
private
115146

116147
def validate_bans_structure
@@ -165,37 +196,6 @@ def normalize_champion_names
165196
self.priority_picks = priority_picks.transform_values(&:strip)
166197
end
167198

168-
# Calculate what percentage of possible scenarios are covered
169-
def scenario_coverage
170-
return 0 if total_scenarios.zero?
171-
172-
# Simplified coverage calculation
173-
# In a real scenario, this would analyze ban combinations
174-
[((total_scenarios / 10.0) * 100).round(2), 100].min
175-
end
176-
177-
# Check how many opponent comfort picks are banned
178-
def comfort_picks_coverage
179-
comfort = opponent_comfort_picks
180-
return 100 if comfort.empty?
181-
182-
banned = (our_bans & comfort).size
183-
((banned.to_f / comfort.size) * 100).round(2)
184-
end
185-
186-
# Suggest additional bans based on opponent comfort picks
187-
def suggest_bans
188-
comfort = opponent_comfort_picks
189-
already_banned = our_bans || []
190-
191-
(comfort - already_banned).first(5)
192-
end
193-
194-
# Check if we have priority picks for all roles
195-
def blind_pick_ready?
196-
Constants::Player::ROLES.all? { |role| priority_picks&.key?(role) }
197-
end
198-
199199
def log_audit_trail
200200
AuditLog.create!(
201201
organization: organization,

0 commit comments

Comments
 (0)