mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-24 17:04:43 +00:00
Updated db seeding for all tournament types
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
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).select{|m| m.finished != 1}.each do |match|
|
||||
match.reload
|
||||
if match.wrestler1.bracket_line < match.wrestler2.bracket_line and match.w1
|
||||
match.winner_id = match.w1
|
||||
elsif match.w2
|
||||
match.winner_id = match.w2
|
||||
end
|
||||
if match.winner_id
|
||||
match.finished = 1
|
||||
match.score = "2-1"
|
||||
match.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
28
lib/tasks/finish_seed_tournaments.rake
Normal file
28
lib/tasks/finish_seed_tournaments.rake
Normal file
@@ -0,0 +1,28 @@
|
||||
task :finish_seed_tournaments => :environment do
|
||||
finish_tournament(tournament_id)
|
||||
@tournament = Tournament.where(:id => tournament_id).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).select{|m| m.finished != 1}.each do |match|
|
||||
match.reload
|
||||
if match.wrestler1.bracket_line < match.wrestler2.bracket_line and match.w1
|
||||
match.winner_id = match.w1
|
||||
elsif match.w2
|
||||
match.winner_id = match.w2
|
||||
end
|
||||
if match.winner_id
|
||||
match.finished = 1
|
||||
match.score = "2-1"
|
||||
match.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
finish_tournament(200)
|
||||
finish_tournament(201)
|
||||
finish_tournament(202)
|
||||
finish_tournament(203)
|
||||
finish_tournament(204)
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user