@@ -202,12 +202,13 @@ def import
202202 begin
203203 # Fetch summoner data from Riot API
204204 summoner_data = fetch_summoner_by_name ( summoner_name , region , riot_api_key )
205- ranked_data = fetch_ranked_stats ( summoner_data [ 'id ' ] , region , riot_api_key )
205+ ranked_data = fetch_ranked_stats ( summoner_data [ 'puuid ' ] , region , riot_api_key )
206206
207207 # Prepare player data
208208 player_data = {
209209 summoner_name : summoner_name ,
210210 role : role ,
211+ region : region ,
211212 status : 'active' ,
212213 riot_puuid : summoner_data [ 'puuid' ] ,
213214 riot_summoner_id : summoner_data [ 'id' ] ,
@@ -302,8 +303,8 @@ def sync_from_riot
302303 summoner_data = fetch_summoner_by_name ( @player . summoner_name , region , riot_api_key )
303304 end
304305
305- # Get ranked stats
306- ranked_data = fetch_ranked_stats ( summoner_data [ 'id ' ] , region , riot_api_key )
306+ # Get ranked stats using PUUID
307+ ranked_data = fetch_ranked_stats ( summoner_data [ 'puuid ' ] , region , riot_api_key )
307308
308309 # Update player with fresh data
309310 update_data = {
@@ -411,7 +412,7 @@ def player_params
411412 # :role refers to in-game position (top/jungle/mid/adc/support), not user role
412413 # nosemgrep
413414 params . require ( :player ) . permit (
414- :summoner_name , :real_name , :role , :status , :jersey_number ,
415+ :summoner_name , :real_name , :role , :region , : status, :jersey_number ,
415416 :birth_date , :country , :nationality ,
416417 :contract_start_date , :contract_end_date ,
417418 :solo_queue_tier , :solo_queue_rank , :solo_queue_lp ,
@@ -517,11 +518,12 @@ def fetch_summoner_by_puuid(puuid, region, api_key)
517518 JSON . parse ( response . body )
518519 end
519520
520- def fetch_ranked_stats ( summoner_id , region , api_key )
521+ def fetch_ranked_stats ( puuid , region , api_key )
521522 require 'net/http'
522523 require 'json'
523524
524- url = "https://#{ region } .api.riotgames.com/lol/league/v4/entries/by-summoner/#{ summoner_id } "
525+ # Riot API v4 now uses PUUID instead of summoner ID
526+ url = "https://#{ region } .api.riotgames.com/lol/league/v4/entries/by-puuid/#{ puuid } "
525527 uri = URI ( url )
526528 request = Net ::HTTP ::Get . new ( uri )
527529 request [ 'X-Riot-Token' ] = api_key
0 commit comments