Implemented loves export for dump backend

This commit is contained in:
Philipp Wolfer 2023-11-12 00:48:19 +01:00
parent cae7d22a36
commit 238163cb05
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
2 changed files with 16 additions and 2 deletions

View file

@ -44,7 +44,21 @@ func (b DumpBackend) ImportListens(listens []models.Listen, oldestTimestamp time
if listen.ListenedAt.Unix() > result.LastTimestamp.Unix() {
result.LastTimestamp = listen.ListenedAt
}
fmt.Printf("Listen: \"%s\" by %s\n", listen.TrackName, listen.ArtistName())
fmt.Printf("🎶 %v: \"%s\" by %s\n", listen.ListenedAt, listen.TrackName, listen.ArtistName())
}
return result, nil
}
func (b DumpBackend) ImportLoves(loves []models.Love, oldestTimestamp time.Time) (ImportResult, error) {
result := ImportResult{
Count: len(loves),
LastTimestamp: oldestTimestamp,
}
for _, love := range loves {
if love.Created.Unix() > result.LastTimestamp.Unix() {
result.LastTimestamp = love.Created
}
fmt.Printf("❤️ %v: \"%s\" by %s\n", love.Created, love.TrackName, love.ArtistName())
}
return result, nil
}

View file

@ -49,7 +49,7 @@ type LovesExport interface {
}
type LovesImport interface {
ExportLoves(loves []models.Love, oldestTimestamp time.Time) (ImportResult, error)
ImportLoves(loves []models.Love, oldestTimestamp time.Time) (ImportResult, error)
}
type ImportResult struct {