Adjust request rate limiting#34
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adjusts request rate limiting for IGDB API calls and fixes a critical bug in game data mapping. The changes improve the robustness of the game data retrieval process by correctly matching IGDB data to games in the collection.
- Fixes incorrect array indexing when mapping IGDB data back to the game collection
- Updates test expectations to match more specific mock data
- Adds debug logging to help with troubleshooting
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/domain/clz-translation/translate.go | Fixes critical bug in game data mapping by matching IGDB IDs instead of using incorrect array indices |
| src/domain/clz-translation/translate_test.go | Updates test expectations to match new mock data with game-specific content |
| src/adapters/igdb/igdb.go | Adds debug logging for fuzzy find operations |
| src/adapters/igdb/igdb_test.go | Adds debug logging for test verification |
| src/_test/mocks/mocks.go | Adds new mock data entry for "1Xtreme (Greatest Hits)" |
Comments suppressed due to low confidence (2)
src/adapters/igdb/igdb_test.go:49
- Debug print statements in tests should be removed or replaced with proper test assertions. These prints don't verify behavior and may clutter test output.
fmt.Println("Game Data count:", len(gameData))
src/adapters/igdb/igdb_test.go:50
- Debug print statements in tests should be removed or replaced with proper test assertions. These prints don't verify behavior and may clutter test output.
fmt.Printf("Game Data: %+v\n", gameData[0].Cover)
| if collectionIndex >= len(gameCollectionWithIgdbIds) { | ||
| fmt.Printf("Skipping index %d as it exceeds gameCollectionWithIgdbIds length %d\n", collectionIndex, len(gameCollectionWithIgdbIds)) | ||
| continue | ||
| } | ||
|
|
There was a problem hiding this comment.
This bounds check is redundant because matchIdx is found by iterating through gameCollectionWithIgdbIds, so it will always be within bounds. If matchIdx is -1, the code already continues on line 246.
| if collectionIndex >= len(gameCollectionWithIgdbIds) { | |
| fmt.Printf("Skipping index %d as it exceeds gameCollectionWithIgdbIds length %d\n", collectionIndex, len(gameCollectionWithIgdbIds)) | |
| continue | |
| } |
| collectionIndex = matchIdx | ||
|
|
||
| if collectionIndex >= len(gameCollectionWithIgdbIds) { | ||
| fmt.Printf("Skipping index %d as it exceeds gameCollectionWithIgdbIds length %d\n", collectionIndex, len(gameCollectionWithIgdbIds)) | ||
| continue | ||
| } | ||
|
|
||
| gameCollectionWithIgdbIds[collectionIndex].FirstReleaseDate = time.Unix(int64(data.First_release_date), 0) | ||
| gameCollectionWithIgdbIds[collectionIndex].Storyline = data.Storyline | ||
| gameCollectionWithIgdbIds[collectionIndex].Summary = data.Summary | ||
| gameCollectionWithIgdbIds[collectionIndex].Cover = domain.Cover{ |
There was a problem hiding this comment.
The variable collectionIndex is unnecessary. You can use matchIdx directly in the subsequent operations instead of assigning it to another variable.
| collectionIndex = matchIdx | |
| if collectionIndex >= len(gameCollectionWithIgdbIds) { | |
| fmt.Printf("Skipping index %d as it exceeds gameCollectionWithIgdbIds length %d\n", collectionIndex, len(gameCollectionWithIgdbIds)) | |
| continue | |
| } | |
| gameCollectionWithIgdbIds[collectionIndex].FirstReleaseDate = time.Unix(int64(data.First_release_date), 0) | |
| gameCollectionWithIgdbIds[collectionIndex].Storyline = data.Storyline | |
| gameCollectionWithIgdbIds[collectionIndex].Summary = data.Summary | |
| gameCollectionWithIgdbIds[collectionIndex].Cover = domain.Cover{ | |
| if matchIdx >= len(gameCollectionWithIgdbIds) { | |
| fmt.Printf("Skipping index %d as it exceeds gameCollectionWithIgdbIds length %d\n", matchIdx, len(gameCollectionWithIgdbIds)) | |
| continue | |
| } | |
| gameCollectionWithIgdbIds[matchIdx].FirstReleaseDate = time.Unix(int64(data.First_release_date), 0) | |
| gameCollectionWithIgdbIds[matchIdx].Storyline = data.Storyline | |
| gameCollectionWithIgdbIds[matchIdx].Summary = data.Summary | |
| gameCollectionWithIgdbIds[matchIdx].Cover = domain.Cover{ |
| // Normalize the game title | ||
| normalizedTitle := GameTitleNormalization(title) | ||
|
|
||
| fmt.Printf("FuzzyFind for title: %s\n", normalizedTitle) |
There was a problem hiding this comment.
Debug print statements should be removed from production code or replaced with proper logging using a logging framework.
| fmt.Printf("FuzzyFind for title: %s\n", normalizedTitle) | |
| log.Printf("FuzzyFind for title: %s", normalizedTitle) |
| // if multiple games returned, find the entry with a matching platform | ||
| if len(gamesData) > 1 { | ||
| for _, game := range gamesData { | ||
| fmt.Printf("FuzzyFind found game: %s\n", game.Name) |
There was a problem hiding this comment.
Debug print statements should be removed from production code or replaced with proper logging using a logging framework.
| fmt.Printf("FuzzyFind found game: %s\n", game.Name) | |
| log.Printf("FuzzyFind found game: %s", game.Name) |
| for _, game := range gamesData { | ||
| fmt.Printf("FuzzyFind found game: %s\n", game.Name) | ||
| for _, platform := range game.Platforms { | ||
| fmt.Printf("Platform: %s\n", domain.PlatformMap.IGDBToCLZ[platform]) |
There was a problem hiding this comment.
Debug print statements should be removed from production code or replaced with proper logging using a logging framework.
| fmt.Printf("Platform: %s\n", domain.PlatformMap.IGDBToCLZ[platform]) | |
| log.Printf("Platform: %s\n", domain.PlatformMap.IGDBToCLZ[platform]) |
No description provided.