mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-18 11:09:29 +02:00
Fixed import count updates
This commit is contained in:
parent
56eae67292
commit
08876a2d70
4 changed files with 4 additions and 5 deletions
|
@ -134,7 +134,7 @@ func (b *ScrobblerLogBackend) ImportListens(export models.ListensResult, importR
|
||||||
}
|
}
|
||||||
|
|
||||||
importResult.UpdateTimestamp(lastTimestamp)
|
importResult.UpdateTimestamp(lastTimestamp)
|
||||||
importResult.ImportCount = len(export.Listens)
|
importResult.ImportCount += len(export.Listens)
|
||||||
progress <- models.Progress{}.FromImportResult(importResult)
|
progress <- models.Progress{}.FromImportResult(importResult)
|
||||||
|
|
||||||
return importResult, nil
|
return importResult, nil
|
||||||
|
|
|
@ -74,7 +74,6 @@ func (b *SpotifyApiBackend) ExportListens(oldestTimestamp time.Time, results cha
|
||||||
|
|
||||||
p := models.Progress{Total: int64(totalDuration.Seconds())}
|
p := models.Progress{Total: int64(totalDuration.Seconds())}
|
||||||
|
|
||||||
out:
|
|
||||||
for {
|
for {
|
||||||
result, err := b.client.RecentlyPlayedAfter(minTime, MaxItemsPerGet)
|
result, err := b.client.RecentlyPlayedAfter(minTime, MaxItemsPerGet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -114,7 +113,7 @@ out:
|
||||||
} else {
|
} else {
|
||||||
// result contains listens older then oldestTimestamp,
|
// result contains listens older then oldestTimestamp,
|
||||||
// we can stop requesting more
|
// we can stop requesting more
|
||||||
break out
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ func (i *ImportResult) UpdateTimestamp(newTime time.Time) {
|
||||||
|
|
||||||
func (i *ImportResult) Update(from ImportResult) {
|
func (i *ImportResult) Update(from ImportResult) {
|
||||||
i.TotalCount = from.TotalCount
|
i.TotalCount = from.TotalCount
|
||||||
i.ImportCount += from.ImportCount
|
i.ImportCount = from.ImportCount
|
||||||
i.UpdateTimestamp(from.LastTimestamp)
|
i.UpdateTimestamp(from.LastTimestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ func TestImportResultUpdate(t *testing.T) {
|
||||||
}
|
}
|
||||||
result.Update(newResult)
|
result.Update(newResult)
|
||||||
assert.Equal(t, 120, result.TotalCount)
|
assert.Equal(t, 120, result.TotalCount)
|
||||||
assert.Equal(t, 70, result.ImportCount)
|
assert.Equal(t, 50, result.ImportCount)
|
||||||
assert.Equal(t, newResult.LastTimestamp, result.LastTimestamp)
|
assert.Equal(t, newResult.LastTimestamp, result.LastTimestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue