diff --git a/jobs/sync-jikan-anime/sync-jikan-anime.go b/jobs/sync-jikan-anime/sync-jikan-anime.go index 9e2ff5d7..d3942841 100644 --- a/jobs/sync-jikan-anime/sync-jikan-anime.go +++ b/jobs/sync-jikan-anime/sync-jikan-anime.go @@ -10,8 +10,6 @@ import ( "github.com/fatih/color" ) -const maxRetries = 3 - var jikanDB = arn.Node.Namespace("jikan") func main() { @@ -38,23 +36,17 @@ func main() { func sync(anime *arn.Anime, malID string) { fmt.Printf("%s %s (MAL: %s)\n", anime.ID, anime.Title.Canonical, malID) - if !jikanDB.Exists("Anime", malID) { - var anime *jikan.Anime - var err error - - for try := 1; try <= maxRetries; try++ { - time.Sleep(time.Second) - anime, err = jikan.GetAnime(malID) - - if err == nil { - jikanDB.Set("Anime", malID, anime) - return - } - - fmt.Printf("Error fetching %s on try %d: %v", malID, try, err) - - // Wait an additional second - time.Sleep(time.Second) - } + if jikanDB.Exists("Anime", malID) { + return } + + time.Sleep(time.Second) + jikanAnime, err := jikan.GetAnime(malID) + + if err == nil { + jikanDB.Set("Anime", malID, jikanAnime) + return + } + + fmt.Printf("Error fetching %s: %v", malID, err) } diff --git a/jobs/sync-jikan-characters/sync-jikan-characters.go b/jobs/sync-jikan-characters/sync-jikan-characters.go index 4fea478c..20fe1b6a 100644 --- a/jobs/sync-jikan-characters/sync-jikan-characters.go +++ b/jobs/sync-jikan-characters/sync-jikan-characters.go @@ -10,8 +10,6 @@ import ( "github.com/fatih/color" ) -const maxRetries = 3 - var jikanDB = arn.Node.Namespace("jikan") func main() { @@ -49,23 +47,17 @@ func main() { func fetchCharacter(malCharacterID string) { fmt.Printf("Fetching character ID %s\n", malCharacterID) - if !jikanDB.Exists("Character", malCharacterID) { - var character *jikan.Character - var err error - - for try := 1; try <= maxRetries; try++ { - time.Sleep(time.Second) - character, err = jikan.GetCharacter(malCharacterID) - - if err == nil { - jikanDB.Set("Character", malCharacterID, character) - return - } - - fmt.Printf("Error fetching %s on try %d: %v", malCharacterID, try, err) - - // Wait an additional second - time.Sleep(time.Second) - } + if jikanDB.Exists("Character", malCharacterID) { + return } + + time.Sleep(time.Second) + character, err := jikan.GetCharacter(malCharacterID) + + if err == nil { + jikanDB.Set("Character", malCharacterID, character) + return + } + + fmt.Printf("Error fetching %s: %v", malCharacterID, err) }