Fetch first 400 deals

This commit is contained in:
Dave Gallant
2022-08-19 23:13:18 +00:00
parent 27c5e2a527
commit 269b394d3e
3 changed files with 24 additions and 20 deletions

View File

@@ -101,8 +101,10 @@ func (a *App) refreshDeals() {
func (a *App) getDeals(id int, firstPage int, lastPage int) []Topic {
// TODO: Fetch multiple pages
requestURL := fmt.Sprintf("https://forums.redflagdeals.com/api/topics?forum_id=%d&per_page=40&page=%d", id, firstPage)
var t []Topic
for i := firstPage; i < lastPage; i++ {
requestURL := fmt.Sprintf("https://forums.redflagdeals.com/api/topics?forum_id=%d&per_page=40&page=%d", id, i)
res, err := http.Get(requestURL)
if err != nil {
log.Warn().Msgf("error fetching deals: %s\n", err)
@@ -120,5 +122,7 @@ func (a *App) getDeals(id int, firstPage int, lastPage int) []Topic {
log.Warn().Msgf("could not unmarshal response body: %s\n", err)
}
return response.Topics
t = append(t, response.Topics...)
}
return t
}

Binary file not shown.

View File

@@ -31,7 +31,7 @@
>
<td scope="col">
<a
href="'https://forums.redflagdeals.com' + topic.web_path"
:href="`https://forums.redflagdeals.com${topic.web_path}`"
target="_blank"
v-html="highlightMatches(topic.title)"
></a>