mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Associated Weight and Match-- the FK already existed in the domain Reduced argument counts on assignLoserNames and assignBouts; trying to pass a Tournament around more This was a tough nut to crack. Looking back, I tried to eat too much of the horse at once on this refactor.
17 lines
350 B
Ruby
17 lines
350 B
Ruby
class Boutgen
|
|
|
|
def matchesByRound(tournament, round)
|
|
tournament.matches.joins(:weight).where(round: round).order("weights.max")
|
|
end
|
|
|
|
def assignBouts(tournament)
|
|
bout_counts = Hash.new(0)
|
|
matches = tournament.matches.each do |m|
|
|
m.bout_number = m.round * 1000 + bout_counts[m.round]
|
|
bout_counts[m.round] += 1
|
|
m.save!
|
|
end
|
|
end
|
|
|
|
end
|