mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Fixed mat assignment when matches are finished
This commit is contained in:
@@ -21,7 +21,7 @@ class Mat < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def assignNextMatch
|
||||
t_matches = tournament.matches.select{|m| m.mat_id == nil}
|
||||
t_matches = tournament.matches.select{|m| m.mat_id == nil && m.finished != 1}
|
||||
if t_matches.size > 0
|
||||
match = t_matches.sort_by{|m| m.bout_number}.first
|
||||
match.mat_id = self.id
|
||||
|
||||
@@ -54,7 +54,9 @@ class Match < ActiveRecord::Base
|
||||
@w2 = wrestler2
|
||||
@w1.advanceInBracket
|
||||
@w2.advanceInBracket
|
||||
self.mat.assignNextMatch
|
||||
if self.mat
|
||||
self.mat.assignNextMatch
|
||||
end
|
||||
end
|
||||
end
|
||||
if Rails.env.production?
|
||||
|
||||
@@ -79,7 +79,7 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def resetMats
|
||||
matchesToReset = matches.select{|m| m.finished != 1 && m.mat_id != nil}
|
||||
matchesToReset = matches.select{|m| m.mat_id != nil}
|
||||
# matchesToReset.update_all( {:mat_id => nil } )
|
||||
matchesToReset.each do |m|
|
||||
m.mat_id = nil
|
||||
|
||||
Reference in New Issue
Block a user