1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00
Files
wrestlingdev.com/app/models/boutgen.rb
RJ Osborne c041286943 rough cut of getting rid of the matches collection being passed around
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.
2015-05-26 19:26:15 -04:00

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