mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
extracted wrestlers_for_pool method
removed unnecessary select
This commit is contained in:
@@ -16,7 +16,7 @@ class Pool
|
|||||||
|
|
||||||
def roundRobin
|
def roundRobin
|
||||||
matches = []
|
matches = []
|
||||||
wrestlers = @weight.wrestlers.select{|w| w.generatePoolNumber == @pool}.to_a
|
wrestlers = @weight.wrestlers_for_pool(@pool)
|
||||||
poolMatches = RoundRobinTournament.schedule(wrestlers).reverse
|
poolMatches = RoundRobinTournament.schedule(wrestlers).reverse
|
||||||
poolMatches.each_with_index do |b, index|
|
poolMatches.each_with_index do |b, index|
|
||||||
round = index + 1
|
round = index + 1
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ class Tournament < ActiveRecord::Base
|
|||||||
|
|
||||||
def upcomingMatches
|
def upcomingMatches
|
||||||
if matches.nil?
|
if matches.nil?
|
||||||
return matches
|
return nil
|
||||||
else
|
else
|
||||||
generateMatchups
|
generateMatchups
|
||||||
return matches
|
matches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ class Tournamentmatchgen
|
|||||||
def buildTournamentWeights
|
def buildTournamentWeights
|
||||||
@tournament.weights.sort_by{|x|[x.max]}.each do |weight|
|
@tournament.weights.sort_by{|x|[x.max]}.each do |weight|
|
||||||
matches = Pool.new(weight).generatePools()
|
matches = Pool.new(weight).generatePools()
|
||||||
weight_matches = matches.select{|m| m.weight_id == weight.id }
|
last_match = matches.sort_by{|m| m.round}.last
|
||||||
last_match = weight_matches.sort_by{|m| m.round}.last
|
|
||||||
highest_round = last_match.round
|
highest_round = last_match.round
|
||||||
@matches += Poolbracket.new.generateBracketMatches(matches, weight, highest_round)
|
@matches += Poolbracket.new.generateBracketMatches(matches, weight, highest_round)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ class Weight < ActiveRecord::Base
|
|||||||
self.tournament.destroyAllMatches
|
self.tournament.destroyAllMatches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def wrestlers_for_pool(pool)
|
||||||
|
wrestlers.select{|w| w.generatePoolNumber == pool}.to_a
|
||||||
|
end
|
||||||
|
|
||||||
def pools
|
def pools
|
||||||
@wrestlers = self.wrestlers
|
@wrestlers = self.wrestlers
|
||||||
if @wrestlers.size <= 6
|
if @wrestlers.size <= 6
|
||||||
|
|||||||
Reference in New Issue
Block a user