mirror of
https://git.sr.ht/~phw/scotty
synced 2025-05-31 10:58:35 +02:00
Revert "jspf/scrobblerlog: return results in batches"
This reverts commit a8ce2be5d7
.
This commit is contained in:
parent
b7ce09041e
commit
5927f41a83
2 changed files with 3 additions and 21 deletions
|
@ -36,7 +36,6 @@ const (
|
|||
artistMBIDPrefix = "https://musicbrainz.org/artist/"
|
||||
recordingMBIDPrefix = "https://musicbrainz.org/recording/"
|
||||
releaseMBIDPrefix = "https://musicbrainz.org/release/"
|
||||
batchSize = 1000
|
||||
)
|
||||
|
||||
type JSPFBackend struct {
|
||||
|
@ -108,7 +107,7 @@ func (b *JSPFBackend) ExportListens(ctx context.Context, oldestTimestamp time.Ti
|
|||
return
|
||||
}
|
||||
|
||||
listens := make(models.ListensList, 0, batchSize)
|
||||
listens := make(models.ListensList, 0, len(b.playlist.Tracks))
|
||||
p.Export.Total = int64(len(b.playlist.Tracks))
|
||||
for _, track := range models.IterExportProgress(b.playlist.Tracks, &p, progress) {
|
||||
listen, err := trackAsListen(track)
|
||||
|
@ -116,11 +115,6 @@ func (b *JSPFBackend) ExportListens(ctx context.Context, oldestTimestamp time.Ti
|
|||
listens = append(listens, *listen)
|
||||
p.Export.TotalItems += 1
|
||||
}
|
||||
|
||||
if len(listens) >= batchSize {
|
||||
results <- models.ListensResult{Items: listens}
|
||||
listens = listens[:0]
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(listens)
|
||||
|
@ -156,7 +150,7 @@ func (b *JSPFBackend) ExportLoves(ctx context.Context, oldestTimestamp time.Time
|
|||
return
|
||||
}
|
||||
|
||||
loves := make(models.LovesList, 0, batchSize)
|
||||
loves := make(models.LovesList, 0, len(b.playlist.Tracks))
|
||||
p.Export.Total = int64(len(b.playlist.Tracks))
|
||||
for _, track := range models.IterExportProgress(b.playlist.Tracks, &p, progress) {
|
||||
love, err := trackAsLove(track)
|
||||
|
@ -164,11 +158,6 @@ func (b *JSPFBackend) ExportLoves(ctx context.Context, oldestTimestamp time.Time
|
|||
loves = append(loves, *love)
|
||||
p.Export.TotalItems += 1
|
||||
}
|
||||
|
||||
if len(loves) >= batchSize {
|
||||
results <- models.LovesResult{Items: loves}
|
||||
loves = loves[:0]
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(loves)
|
||||
|
|
|
@ -30,8 +30,6 @@ import (
|
|||
"go.uploadedlobster.com/scotty/pkg/scrobblerlog"
|
||||
)
|
||||
|
||||
const batchSize = 1000
|
||||
|
||||
type ScrobblerLogBackend struct {
|
||||
filePath string
|
||||
ignoreSkipped bool
|
||||
|
@ -154,7 +152,7 @@ func (b *ScrobblerLogBackend) ExportListens(ctx context.Context, oldestTimestamp
|
|||
return
|
||||
}
|
||||
|
||||
listens := make(models.ListensList, 0, batchSize)
|
||||
listens := make(models.ListensList, 0, len(b.log.Records))
|
||||
client := strings.Split(b.log.Client, " ")[0]
|
||||
p.Export.Total = int64(len(b.log.Records))
|
||||
for _, record := range models.IterExportProgress(b.log.Records, &p, progress) {
|
||||
|
@ -163,11 +161,6 @@ func (b *ScrobblerLogBackend) ExportListens(ctx context.Context, oldestTimestamp
|
|||
listens = append(listens, recordToListen(record, client))
|
||||
p.Export.TotalItems += 1
|
||||
}
|
||||
|
||||
if len(listens) >= batchSize {
|
||||
results <- models.ListensResult{Items: listens}
|
||||
listens = listens[:0]
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(listens)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue