Permalink
Browse files

hotfix for stats not posting to player

  • Loading branch information...
1 parent 21bcd99 commit 96b7bfa01801cd6e5c3491dfd324af42a7950c29 @game7 committed Feb 13, 2013
@@ -14,7 +14,7 @@ def name
"#{first_name} #{last_name}"
end
- belongs_to :player
+ belongs_to :player, class_name: "::Player"
embedded_in :statsheet, :class_name => "Hockey::Statsheet"
scope :with_num, ->(n) { where(num: n) }
@@ -248,6 +248,7 @@ def event_deleted(event)
end
def goal_created(goal)
+ puts "GOAL!"
increment_goals_for_player(goal.side, goal.plr, 1)
increment_assists_for_player(goal.side, goal.a1, 1)
increment_assists_for_player(goal.side, goal.a2, 1)
@@ -341,6 +342,7 @@ def calculate_player_stats
end
def clear_player_stats
+ puts '*****************************'
players.each do |plr|
plr.clear_stats
plr.gp = 1 if plr.played
@@ -32,7 +32,9 @@ def self.update_player_stats statsheet
def self.post_player_results statsheet
statsheet.players.each do |p|
+ #player = Player.where(id: p.player_id).first
player = p.player
+ puts 'NO PLAYER' if player.nil?
next if player.nil?
result = p.to_result
player.record.post_result result
@@ -42,8 +44,10 @@ def self.post_player_results statsheet
def self.unpost_player_results statsheet
statsheet.players.each do |p|
+ #player = Player.where(id: p.player_id).first
player = p.player
- next if player.nil?
+ puts 'NO PLAYER' if player.nil?
+ next if player.nil?
player.record.cancel_result_for_game statsheet.game_id
player.save
end
View
@@ -23,6 +23,8 @@ class Player
before_save :ensure_record
before_save :set_slug
+
+ has_many :players
def full_name
[first_name, last_name].join(' ')

0 comments on commit 96b7bfa

Please sign in to comment.