@@ -45,16 +45,25 @@ def create_match_record(match_data, organization)
4545 game_start : match_data [ :game_creation ] ,
4646 game_end : match_data [ :game_creation ] + match_data [ :game_duration ] . seconds ,
4747 game_duration : match_data [ :game_duration ] ,
48- patch_version : match_data [ :game_version ] ,
48+ game_version : match_data [ :game_version ] ,
4949 victory : determine_team_victory ( match_data [ :participants ] , organization )
5050 )
5151 end
5252
5353 def create_player_match_stats ( match , participants , organization )
54+ Rails . logger . info "Creating stats for #{ participants . count } participants"
55+ created_count = 0
56+
5457 participants . each do |participant_data |
5558 # Find player by PUUID
5659 player = organization . players . find_by ( riot_puuid : participant_data [ :puuid ] )
57- next unless player
60+
61+ if player . nil?
62+ Rails . logger . debug "Participant PUUID #{ participant_data [ :puuid ] [ 0 ..20 ] } ... not found in organization"
63+ next
64+ end
65+
66+ Rails . logger . info "Creating stat for player: #{ player . summoner_name } "
5867
5968 PlayerMatchStat . create! (
6069 match : match ,
@@ -65,22 +74,25 @@ def create_player_match_stats(match, participants, organization)
6574 deaths : participant_data [ :deaths ] ,
6675 assists : participant_data [ :assists ] ,
6776 gold_earned : participant_data [ :gold_earned ] ,
68- total_damage_dealt : participant_data [ :total_damage_dealt ] ,
69- total_damage_taken : participant_data [ :total_damage_taken ] ,
70- minions_killed : participant_data [ :minions_killed ] ,
71- jungle_minions_killed : participant_data [ :neutral_minions_killed ] ,
77+ damage_dealt_champions : participant_data [ :total_damage_dealt ] ,
78+ damage_dealt_total : participant_data [ :total_damage_dealt ] ,
79+ damage_taken : participant_data [ :total_damage_taken ] ,
80+ cs : participant_data [ :minions_killed ] . to_i + participant_data [ : neutral_minions_killed] . to_i ,
7281 vision_score : participant_data [ :vision_score ] ,
7382 wards_placed : participant_data [ :wards_placed ] ,
74- wards_killed : participant_data [ :wards_killed ] ,
75- champion_level : participant_data [ :champion_level ] ,
76- first_blood_kill : participant_data [ :first_blood_kill ] ,
83+ wards_destroyed : participant_data [ :wards_killed ] ,
84+ first_blood : participant_data [ :first_blood_kill ] ,
7785 double_kills : participant_data [ :double_kills ] ,
7886 triple_kills : participant_data [ :triple_kills ] ,
7987 quadra_kills : participant_data [ :quadra_kills ] ,
8088 penta_kills : participant_data [ :penta_kills ] ,
8189 performance_score : calculate_performance_score ( participant_data )
8290 )
91+ created_count += 1
92+ Rails . logger . info "Stat created successfully for #{ player . summoner_name } "
8393 end
94+
95+ Rails . logger . info "Created #{ created_count } player match stats"
8496 end
8597
8698 def determine_match_type ( game_mode )
0 commit comments