mirror of
https://github.com/davegallant/rfd-fyi.git
synced 2025-08-07 09:02:27 +00:00
Skip sponsored topics
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
@@ -104,6 +105,10 @@ func (a *App) updateScores(t []Topic) []Topic {
|
|||||||
return t
|
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 {
|
func (a *App) getDeals(id int, firstPage int, lastPage int) []Topic {
|
||||||
|
|
||||||
var t []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)
|
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
|
return t
|
||||||
}
|
}
|
||||||
|
@@ -146,7 +146,7 @@ export default {
|
|||||||
Deal: "deal",
|
Deal: "deal",
|
||||||
Score: "score",
|
Score: "score",
|
||||||
Views: "total_views",
|
Views: "total_views",
|
||||||
"Last Comment": "last_post_time",
|
"Last Reply": "last_post_time",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
filteredTopics() {
|
filteredTopics() {
|
||||||
|
Reference in New Issue
Block a user