mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added a rake task for finishing all matches and updated the readme
This commit is contained in:
17
lib/tasks/finish_seed_tournament.rake
Normal file
17
lib/tasks/finish_seed_tournament.rake
Normal file
@@ -0,0 +1,17 @@
|
||||
task :finish_seed_tournament => :environment do
|
||||
@tournament = Tournament.where(:id => 200).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first
|
||||
GenerateTournamentMatches.new(@tournament).generate
|
||||
(1..@tournament.reload.total_rounds).each do |round|
|
||||
@tournament.reload.matches_by_round(round).each do |match|
|
||||
match.reload
|
||||
if match.wrestler1.bracket_line < match.wrestler2.bracket_line
|
||||
match.winner_id = match.w1
|
||||
else
|
||||
match.winner_id = match.w2
|
||||
end
|
||||
match.finished = 1
|
||||
match.score = "2-1"
|
||||
match.save
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user