mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
listenbrainz: fetch listens in reverse listen time order
This allows parallel import
This commit is contained in:
parent
cde9b28c28
commit
4bf0f2c81d
6 changed files with 34 additions and 20 deletions
|
@ -122,15 +122,14 @@ func (b *SpotifyApiBackend) ExportListens(oldestTimestamp time.Time, results cha
|
|||
break
|
||||
}
|
||||
|
||||
listens := make(models.ListensList, 0, len(result.Items))
|
||||
listens := make(models.ListensList, 0, count)
|
||||
|
||||
for _, listen := range result.Items {
|
||||
l := listen.AsListen()
|
||||
if l.ListenedAt.Unix() > oldestTimestamp.Unix() {
|
||||
listens = append(listens, l)
|
||||
} else {
|
||||
// result contains listens older then oldestTimestamp,
|
||||
// we can stop requesting more
|
||||
// result contains listens older then oldestTimestamp
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue