From 5dd8902472620dfb2ff48976fac6ffca564971f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=20Jurmanovi=C4=87?= Date: Sat, 25 Apr 2026 21:07:15 +0200 Subject: [PATCH] retry if no new suggestions --- internal/service/recommender.go | 8 ++++++-- internal/utl/configs/config.go | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/service/recommender.go b/internal/service/recommender.go index f5180b2..6461494 100644 --- a/internal/service/recommender.go +++ b/internal/service/recommender.go @@ -103,6 +103,11 @@ func (r *Recommender) RunWithCount(count int) ([]model.Recommendation, error) { log.Info().Msgf("TMDb fallback returned %d suggestions (attempt %d)", len(suggestions), attempt+1) } + if len(suggestions) == 0 { + log.Warn().Msgf("No suggestions returned on attempt %d, stopping retries", attempt+1) + break + } + before := len(recommendations) for _, s := range suggestions { if len(recommendations) >= count { @@ -128,8 +133,7 @@ func (r *Recommender) RunWithCount(count int) ([]model.Recommendation, error) { } if len(recommendations) == before { - log.Warn().Msgf("No new recommendations found on attempt %d, stopping retries", attempt+1) - break + log.Info().Msgf("All suggestions on attempt %d were already in library, retrying", attempt+1) } } diff --git a/internal/utl/configs/config.go b/internal/utl/configs/config.go index e1f7005..3345c14 100644 --- a/internal/utl/configs/config.go +++ b/internal/utl/configs/config.go @@ -25,8 +25,8 @@ type Config struct { CronEnabled bool `envconfig:"CRON_ENABLED" default:"false"` CronSchedule string `envconfig:"CRON_SCHEDULE" default:"0 3 * * *"` - APIEnabled bool `envconfig:"API_ENABLED" default:"true"` - APIPort int `envconfig:"API_PORT" default:"8080"` + APIEnabled bool `envconfig:"API_ENABLED" default:"true"` + APIPort int `envconfig:"API_PORT" default:"8080"` APISecretKey string `envconfig:"SECRET_KEY" default:""` RecommendCount int `envconfig:"RECOMMEND_COUNT" default:"10"`