From 5d7c061508b503012929526de61e222fde2e727c Mon Sep 17 00:00:00 2001 From: Dave Gallant Date: Sun, 25 Dec 2022 09:28:50 -0500 Subject: [PATCH] Skip sponsored topics --- backend/app.go | 12 +++++++++++- src/App.vue | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/app.go b/backend/app.go index bf9d21f..ff270ec 100644 --- a/backend/app.go +++ b/backend/app.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "net/http" "os" + "strings" "time" _ "github.com/joho/godotenv/autoload" @@ -104,6 +105,10 @@ func (a *App) updateScores(t []Topic) []Topic { return t } +func (a *App) isSponsor(t Topic) bool { + return strings.HasPrefix(t.Title, "[Sponsored]") +} + func (a *App) getDeals(id int, firstPage int, lastPage int) []Topic { var t []Topic @@ -127,7 +132,12 @@ func (a *App) getDeals(id int, firstPage int, lastPage int) []Topic { log.Warn().Msgf("could not unmarshal response body: %s\n %s", err) } - t = append(t, response.Topics...) + for _, topic := range response.Topics { + if a.isSponsor(topic) { + continue + } + t = append(t, topic) + } } return t } diff --git a/src/App.vue b/src/App.vue index d8cbcc8..7cbb71c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -146,7 +146,7 @@ export default { Deal: "deal", Score: "score", Views: "total_views", - "Last Comment": "last_post_time", + "Last Reply": "last_post_time", }; }, filteredTopics() {