mirror of
https://github.com/FJurmanovic/sugarr.git
synced 2026-11-11 15:51:09 +00:00
retry if no new suggestions
This commit is contained in:
@@ -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)
|
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)
|
before := len(recommendations)
|
||||||
for _, s := range suggestions {
|
for _, s := range suggestions {
|
||||||
if len(recommendations) >= count {
|
if len(recommendations) >= count {
|
||||||
@@ -128,8 +133,7 @@ func (r *Recommender) RunWithCount(count int) ([]model.Recommendation, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(recommendations) == before {
|
if len(recommendations) == before {
|
||||||
log.Warn().Msgf("No new recommendations found on attempt %d, stopping retries", attempt+1)
|
log.Info().Msgf("All suggestions on attempt %d were already in library, retrying", attempt+1)
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user