Skip to content

Adjust request rate limiting#34

Merged
jcarpe merged 4 commits into
mainfrom
adjust-request-rate-limiting
Aug 4, 2025
Merged

Adjust request rate limiting#34
jcarpe merged 4 commits into
mainfrom
adjust-request-rate-limiting

Conversation

@jcarpe

@jcarpe jcarpe commented Aug 4, 2025

Copy link
Copy Markdown
Owner

No description provided.

@jcarpe jcarpe requested a review from Copilot August 4, 2025 02:00
@jcarpe jcarpe merged commit badd943 into main Aug 4, 2025
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +250 to +254
if collectionIndex >= len(gameCollectionWithIgdbIds) {
fmt.Printf("Skipping index %d as it exceeds gameCollectionWithIgdbIds length %d\n", collectionIndex, len(gameCollectionWithIgdbIds))
continue
}

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if collectionIndex >= len(gameCollectionWithIgdbIds) {
fmt.Printf("Skipping index %d as it exceeds gameCollectionWithIgdbIds length %d\n", collectionIndex, len(gameCollectionWithIgdbIds))
continue
}

Copilot uses AI. Check for mistakes.
Comment on lines +248 to +258
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{

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable collectionIndex is unnecessary. You can use matchIdx directly in the subsequent operations instead of assigning it to another variable.

Suggested change
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{

Copilot uses AI. Check for mistakes.
Comment thread src/adapters/igdb/igdb.go
// Normalize the game title
normalizedTitle := GameTitleNormalization(title)

fmt.Printf("FuzzyFind for title: %s\n", normalizedTitle)

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug print statements should be removed from production code or replaced with proper logging using a logging framework.

Suggested change
fmt.Printf("FuzzyFind for title: %s\n", normalizedTitle)
log.Printf("FuzzyFind for title: %s", normalizedTitle)

Copilot uses AI. Check for mistakes.
Comment thread src/adapters/igdb/igdb.go
// 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)

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug print statements should be removed from production code or replaced with proper logging using a logging framework.

Suggested change
fmt.Printf("FuzzyFind found game: %s\n", game.Name)
log.Printf("FuzzyFind found game: %s", game.Name)

Copilot uses AI. Check for mistakes.
Comment thread src/adapters/igdb/igdb.go
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])

Copilot AI Aug 4, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug print statements should be removed from production code or replaced with proper logging using a logging framework.

Suggested change
fmt.Printf("Platform: %s\n", domain.PlatformMap.IGDBToCLZ[platform])
log.Printf("Platform: %s\n", domain.PlatformMap.IGDBToCLZ[platform])

Copilot uses AI. Check for mistakes.
@jcarpe jcarpe deleted the adjust-request-rate-limiting branch August 4, 2025 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants