From 25c92a125d75b3421b80a7e65337a2673494eeba Mon Sep 17 00:00:00 2001 From: RJ Osborne Date: Wed, 27 May 2015 23:04:17 -0400 Subject: [PATCH] Boutgen is dead. Tournaments can assign their own bout numbers. --- app/models/boutgen.rb | 16 ---------------- app/models/tournament.rb | 13 +++++++++++++ app/models/tournamentmatchgen.rb | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 app/models/boutgen.rb diff --git a/app/models/boutgen.rb b/app/models/boutgen.rb deleted file mode 100644 index 8f8c38a..0000000 --- a/app/models/boutgen.rb +++ /dev/null @@ -1,16 +0,0 @@ -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 diff --git a/app/models/tournament.rb b/app/models/tournament.rb index a211705..9dba39d 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -40,4 +40,17 @@ class Tournament < ActiveRecord::Base matches.destroy_all end + def matchesByRound(round) + matches.joins(:weight).where(round: round).order("weights.max") + end + + def assignBouts + bout_counts = Hash.new(0) + matches.each do |m| + m.bout_number = m.round * 1000 + bout_counts[m.round] + bout_counts[m.round] += 1 + m.save! + end + end + end diff --git a/app/models/tournamentmatchgen.rb b/app/models/tournamentmatchgen.rb index 182b5bf..cbbe5cb 100644 --- a/app/models/tournamentmatchgen.rb +++ b/app/models/tournamentmatchgen.rb @@ -31,7 +31,7 @@ class Tournamentmatchgen end def generateMatches - Boutgen.new.assignBouts(@tournament) + @tournament.assignBouts Losernamegen.new.assignLoserNames(@tournament) end end