From 5dd59be6aaabb0ddc8b91f34e6a9e289cf1241ac Mon Sep 17 00:00:00 2001 From: Dave Gallant Date: Sat, 25 Jan 2025 15:15:03 -0500 Subject: [PATCH] Only refresh topics if the list is non-empty If the rfd api returns an empty list of topics (i.e. it's down), do not refresh the topics list. --- backend/app.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/app.go b/backend/app.go index f214474..10436da 100644 --- a/backend/app.go +++ b/backend/app.go @@ -91,12 +91,15 @@ func (a *App) refreshTopics() { for { log.Info().Msg("Refreshing topics") latestTopics := a.getDeals(9, 1, 6) - latestTopics = a.updateScores(latestTopics) - log.Info().Msg("Refreshing redirects") - latestRedirects := a.getRedirects() - a.Redirects = latestRedirects - a.CurrentTopics = a.stripRedirects(latestTopics) + if len(latestTopics) > 0 { + latestTopics = a.updateScores(latestTopics) + + log.Info().Msg("Refreshing redirects") + latestRedirects := a.getRedirects() + a.Redirects = latestRedirects + a.CurrentTopics = a.stripRedirects(latestTopics) + } a.LastRefresh = time.Now() rand.Seed(time.Now().UnixNano())