mirror of
https://github.com/davegallant/rfd-fyi.git
synced 2025-08-06 07:13:39 +00:00
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.
This commit is contained in:
@@ -91,12 +91,15 @@ func (a *App) refreshTopics() {
|
|||||||
for {
|
for {
|
||||||
log.Info().Msg("Refreshing topics")
|
log.Info().Msg("Refreshing topics")
|
||||||
latestTopics := a.getDeals(9, 1, 6)
|
latestTopics := a.getDeals(9, 1, 6)
|
||||||
latestTopics = a.updateScores(latestTopics)
|
|
||||||
|
|
||||||
log.Info().Msg("Refreshing redirects")
|
if len(latestTopics) > 0 {
|
||||||
latestRedirects := a.getRedirects()
|
latestTopics = a.updateScores(latestTopics)
|
||||||
a.Redirects = latestRedirects
|
|
||||||
a.CurrentTopics = a.stripRedirects(latestTopics)
|
log.Info().Msg("Refreshing redirects")
|
||||||
|
latestRedirects := a.getRedirects()
|
||||||
|
a.Redirects = latestRedirects
|
||||||
|
a.CurrentTopics = a.stripRedirects(latestTopics)
|
||||||
|
}
|
||||||
|
|
||||||
a.LastRefresh = time.Now()
|
a.LastRefresh = time.Now()
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
Reference in New Issue
Block a user