Deduplicate deals

This commit is contained in:
2026-02-14 09:22:50 -05:00
parent a091f0ef0e
commit fe616c06c3
2 changed files with 17 additions and 0 deletions

View File

@@ -178,6 +178,7 @@ func (a *App) refreshTopics() {
latestTopics := a.getDeals(9, 1, 6)
if len(latestTopics) > 0 {
latestTopics = a.deduplicateTopics(latestTopics)
latestTopics = a.updateScores(latestTopics)
log.Info().Msg("Refreshing redirects")
@@ -231,6 +232,22 @@ func (a *App) stripRedirects(t []Topic) []Topic {
return t
}
func (a *App) deduplicateTopics(topics []Topic) []Topic {
seen := make(map[uint]bool)
var deduplicated []Topic
for _, topic := range topics {
if !seen[topic.TopicID] {
seen[topic.TopicID] = true
deduplicated = append(deduplicated, topic)
} else {
log.Debug().Msgf("Removing duplicate topic: %d", topic.TopicID)
}
}
return deduplicated
}
func (a *App) isSponsor(t Topic) bool {
return strings.HasPrefix(t.Title, "[Sponsored]")
}

BIN
backend/rfd-fyi Executable file

Binary file not shown.