diff options
| author | NeKz <NeKzor@users.noreply.github.com> | 2024-11-18 08:54:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-18 10:54:57 +0300 |
| commit | 780bcf4e02704553f0e3c4879c60230040bfa6f4 (patch) | |
| tree | 36fafa2b007561df9c627b5ad6fce5e064e0bdc8 /rankings/fetch.go | |
| parent | feat/rankings: make sorting stable (#235) (diff) | |
| download | lphub-780bcf4e02704553f0e3c4879c60230040bfa6f4.tar.gz lphub-780bcf4e02704553f0e3c4879c60230040bfa6f4.tar.bz2 lphub-780bcf4e02704553f0e3c4879c60230040bfa6f4.zip | |
feat/rankings: optimize Steam ID comparison (#236)
Diffstat (limited to 'rankings/fetch.go')
| -rw-r--r-- | rankings/fetch.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/rankings/fetch.go b/rankings/fetch.go index cf04e81..7e63427 100644 --- a/rankings/fetch.go +++ b/rankings/fetch.go | |||
| @@ -12,9 +12,9 @@ import ( | |||
| 12 | "strings" | 12 | "strings" |
| 13 | ) | 13 | ) |
| 14 | 14 | ||
| 15 | func fetchLeaderboard(records []Record, overrides map[string]map[string]int, useCache bool) map[string]*Player { | 15 | func fetchLeaderboard(records []Record, overrides map[SteamID]map[string]int, useCache bool) map[SteamID]*Player { |
| 16 | log.Println("fetching leaderboard") | 16 | log.Println("fetching leaderboard") |
| 17 | players := map[string]*Player{} | 17 | players := map[SteamID]*Player{} |
| 18 | // first init players map with records from portal gun and doors | 18 | // first init players map with records from portal gun and doors |
| 19 | fetchAnotherPage := true | 19 | fetchAnotherPage := true |
| 20 | start := 0 | 20 | start := 0 |
| @@ -187,7 +187,7 @@ func fetchPlayerInfo(players []*Player) { | |||
| 187 | 187 | ||
| 188 | ids := make([]string, len(players)) | 188 | ids := make([]string, len(players)) |
| 189 | for _, player := range players { | 189 | for _, player := range players { |
| 190 | ids = append(ids, player.SteamID) | 190 | ids = append(ids, strconv.FormatInt(int64(player.SteamID), 10)) |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", os.Getenv("API_KEY"), strings.Join(ids, ",")) | 193 | url := fmt.Sprintf("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=%s&steamids=%s", os.Getenv("API_KEY"), strings.Join(ids, ",")) |
| @@ -200,9 +200,9 @@ func fetchPlayerInfo(players []*Player) { | |||
| 200 | log.Fatalln(err.Error()) | 200 | log.Fatalln(err.Error()) |
| 201 | } | 201 | } |
| 202 | type PlayerSummary struct { | 202 | type PlayerSummary struct { |
| 203 | SteamID string `json:"steamid"` | 203 | SteamID SteamID `json:"steamid"` |
| 204 | PersonaName string `json:"personaname"` | 204 | PersonaName string `json:"personaname"` |
| 205 | AvatarFull string `json:"avatarfull"` | 205 | AvatarFull string `json:"avatarfull"` |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | type Result struct { | 208 | type Result struct { |