mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-18 19:19:28 +02:00
Implemented loves export for dump backend
This commit is contained in:
parent
cae7d22a36
commit
238163cb05
2 changed files with 16 additions and 2 deletions
|
@ -44,7 +44,21 @@ func (b DumpBackend) ImportListens(listens []models.Listen, oldestTimestamp time
|
||||||
if listen.ListenedAt.Unix() > result.LastTimestamp.Unix() {
|
if listen.ListenedAt.Unix() > result.LastTimestamp.Unix() {
|
||||||
result.LastTimestamp = listen.ListenedAt
|
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
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ type LovesExport interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type LovesImport 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 {
|
type ImportResult struct {
|
||||||
|
|
Loading…
Add table
Reference in a new issue