@@ -16,26 +16,26 @@ module Services
1616 class ScraperImporterService
1717 # Leaguepedia role values mapped to our internal lowercase convention
1818 ROLE_MAP = {
19- 'Top' => 'top' ,
20- 'Jungle' => 'jungle' ,
21- 'Mid' => 'mid' ,
22- 'Bot' => 'adc' ,
19+ 'Top' => 'top' ,
20+ 'Jungle' => 'jungle' ,
21+ 'Mid' => 'mid' ,
22+ 'Bot' => 'adc' ,
2323 'Support' => 'support'
2424 } . freeze
2525
2626 # Derive broad tournament region from league slug
2727 LEAGUE_REGION = {
28- 'CBLOL' => 'BR' ,
29- 'LCS' => 'NA' ,
30- 'LEC' => 'EUW' ,
31- 'LCK' => 'KR' ,
32- 'LPL' => 'CN' ,
33- 'LLA' => 'LATAM' ,
34- 'PCS' => 'SEA' ,
35- 'VCS' => 'VCS' ,
36- 'TCL' => 'TR' ,
37- 'LJL' => 'JP' ,
38- 'CBLOL_A' => 'BR'
28+ 'CBLOL' => 'BR' ,
29+ 'LCS' => 'NA' ,
30+ 'LEC' => 'EUW' ,
31+ 'LCK' => 'KR' ,
32+ 'LPL' => 'CN' ,
33+ 'LLA' => 'LATAM' ,
34+ 'PCS' => 'SEA' ,
35+ 'VCS' => 'VCS' ,
36+ 'TCL' => 'TR' ,
37+ 'LJL' => 'JP' ,
38+ 'CBLOL_A' => 'BR'
3939 } . freeze
4040
4141 def initialize ( organization )
@@ -111,23 +111,23 @@ def build_attributes(match, ext_id, our_team)
111111 our_resolved , opp_resolved = resolve_teams ( team1_name , team2_name , win_team , our_team )
112112
113113 {
114- organization : @organization ,
115- tournament_name : league ,
116- tournament_stage : match [ 'stage' ] ,
117- tournament_region : LEAGUE_REGION [ league ] ,
118- external_match_id : ext_id ,
119- match_date : parse_date ( match [ 'start_time' ] ) ,
120- game_number : match [ 'game_number' ] ,
121- patch_version : match [ 'patch' ] ,
122- vod_url : build_vod_url ( match [ 'vod_youtube_id' ] ) ,
123- our_team_name : our_resolved ,
114+ organization : @organization ,
115+ tournament_name : league ,
116+ tournament_stage : match [ 'stage' ] ,
117+ tournament_region : LEAGUE_REGION [ league ] ,
118+ external_match_id : ext_id ,
119+ match_date : parse_date ( match [ 'start_time' ] ) ,
120+ game_number : match [ 'game_number' ] ,
121+ patch_version : match [ 'patch' ] ,
122+ vod_url : build_vod_url ( match [ 'vod_youtube_id' ] ) ,
123+ our_team_name : our_resolved ,
124124 opponent_team_name : opp_resolved ,
125- victory : determine_victory ( our_resolved , win_team ) ,
125+ victory : determine_victory ( our_resolved , win_team ) ,
126126 # In Leaguepedia/LoL Esports convention, team1 is always blue side.
127- side : derive_side ( our_resolved , team1_name ) ,
128- our_picks : build_picks ( match [ 'participants' ] , our_resolved ) ,
129- opponent_picks : build_picks ( match [ 'participants' ] , opp_resolved ) ,
130- game_stats : build_game_stats ( match , team1_name , team2_name )
127+ side : derive_side ( our_resolved , team1_name ) ,
128+ our_picks : build_picks ( match [ 'participants' ] , our_resolved ) ,
129+ opponent_picks : build_picks ( match [ 'participants' ] , opp_resolved ) ,
130+ game_stats : build_game_stats ( match , team1_name , team2_name )
131131 }
132132 end
133133
@@ -174,13 +174,13 @@ def build_picks(participants, team_name)
174174 . select { |p | teams_match? ( p [ 'team_name' ] . to_s , team_name ) }
175175 . map do |p |
176176 {
177- 'champion' => p [ 'champion_name' ] ,
178- 'role' => normalize_role ( p [ 'role' ] ) ,
177+ 'champion' => p [ 'champion_name' ] ,
178+ 'role' => normalize_role ( p [ 'role' ] ) ,
179179 'summoner_name' => p [ 'summoner_name' ] ,
180- 'kills' => p [ 'kills' ] ,
181- 'deaths' => p [ 'deaths' ] ,
182- 'assists' => p [ 'assists' ] ,
183- 'win' => p [ 'win' ]
180+ 'kills' => p [ 'kills' ] ,
181+ 'deaths' => p [ 'deaths' ] ,
182+ 'assists' => p [ 'assists' ] ,
183+ 'win' => p [ 'win' ]
184184 } . compact
185185 end
186186 end
@@ -194,15 +194,15 @@ def normalize_role(role)
194194 # so that side can be retroactively derived (team1 = blue side convention).
195195 def build_game_stats ( match , team1_name = nil , team2_name = nil )
196196 {
197- 'source' => 'prostaff_scraper' ,
198- 'enrichment_source' => match [ 'enrichment_source' ] ,
199- 'leaguepedia_page' => match [ 'leaguepedia_page' ] ,
200- 'gamelength' => match [ 'gamelength' ] ,
197+ 'source' => 'prostaff_scraper' ,
198+ 'enrichment_source' => match [ 'enrichment_source' ] ,
199+ 'leaguepedia_page' => match [ 'leaguepedia_page' ] ,
200+ 'gamelength' => match [ 'gamelength' ] ,
201201 'game_duration_seconds' => match [ 'game_duration_seconds' ] ,
202- 'win_team' => match [ 'win_team' ] ,
203- 'team1_name' => team1_name . presence || match . dig ( 'team1' , 'name' ) ,
204- 'team2_name' => team2_name . presence || match . dig ( 'team2' , 'name' ) ,
205- 'participants' => match [ 'participants' ] || [ ]
202+ 'win_team' => match [ 'win_team' ] ,
203+ 'team1_name' => team1_name . presence || match . dig ( 'team1' , 'name' ) ,
204+ 'team2_name' => team2_name . presence || match . dig ( 'team2' , 'name' ) ,
205+ 'participants' => match [ 'participants' ] || [ ]
206206 } . compact
207207 end
208208
0 commit comments