1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-08 07:22:38 +00:00

Fixed mat assignment when matches are finished

This commit is contained in:
2016-01-11 16:48:08 +00:00
parent a2c0a2763e
commit cce30bdf3a
3 changed files with 5 additions and 3 deletions

View File

@@ -21,7 +21,7 @@ class Mat < ActiveRecord::Base
end end
def assignNextMatch 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 if t_matches.size > 0
match = t_matches.sort_by{|m| m.bout_number}.first match = t_matches.sort_by{|m| m.bout_number}.first
match.mat_id = self.id match.mat_id = self.id

View File

@@ -54,7 +54,9 @@ class Match < ActiveRecord::Base
@w2 = wrestler2 @w2 = wrestler2
@w1.advanceInBracket @w1.advanceInBracket
@w2.advanceInBracket @w2.advanceInBracket
self.mat.assignNextMatch if self.mat
self.mat.assignNextMatch
end
end end
end end
if Rails.env.production? if Rails.env.production?

View File

@@ -79,7 +79,7 @@ class Tournament < ActiveRecord::Base
end end
def resetMats 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.update_all( {:mat_id => nil } )
matchesToReset.each do |m| matchesToReset.each do |m|
m.mat_id = nil m.mat_id = nil