Verified Commit feda5102 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Better handling of toots date

parent e2741625
Pipeline #4241 passed with stages
in 1 minute and 18 seconds
...@@ -98,14 +98,20 @@ export default { ...@@ -98,14 +98,20 @@ export default {
// results.progress = 0 // results.progress = 0
// results.progressCount // results.progressCount
results.accounts = {} results.accounts = {}
let cont = true let tooOld = 0
while (cont) { let maxOld = 5
while (tooOld < maxOld) {
let response = await client.get(url, {params: {limit: 40}}) let response = await client.get(url, {params: {limit: 40}})
response.data.forEach((f) => { response.data.forEach((f) => {
let date = moment(f.created_at) let date = moment(f.created_at)
// ugly hack because we don't have any way to query favorite date, and mastodon
// return toots in reverse favorite date order, so favoriting a very old toot
// can result in little to no suggestions
if (date.isBefore(dateLimit)) { if (date.isBefore(dateLimit)) {
cont = false tooOld += 1
return } else {
// we reset the counter
tooOld = 0
} }
handledFavorites += 1 handledFavorites += 1
results.progressCount += 1 results.progressCount += 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment