mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 13:47:05 +02:00
Reduced redundancy in model conversions and consistent naming
This commit is contained in:
parent
e29d8e2a63
commit
cac88f316b
10 changed files with 107 additions and 107 deletions
|
@ -73,7 +73,7 @@ out:
|
|||
for _, scrobble := range result.List {
|
||||
if scrobble.ListenedAt > oldestTimestamp.Unix() {
|
||||
p.Elapsed += 1
|
||||
listens = append(listens, scrobble.ToListen())
|
||||
listens = append(listens, scrobble.AsListen())
|
||||
} else {
|
||||
break out
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ func (b *MalojaApiBackend) ImportListens(export models.ListensResult, importResu
|
|||
return importResult, nil
|
||||
}
|
||||
|
||||
func (s Scrobble) ToListen() models.Listen {
|
||||
func (s Scrobble) AsListen() models.Listen {
|
||||
track := s.Track
|
||||
listen := models.Listen{
|
||||
ListenedAt: time.Unix(s.ListenedAt, 0),
|
||||
|
|
|
@ -32,7 +32,7 @@ func TestFromConfig(t *testing.T) {
|
|||
assert.IsType(t, &maloja.MalojaApiBackend{}, backend)
|
||||
}
|
||||
|
||||
func TestScrobbleToListen(t *testing.T) {
|
||||
func TestScrobbleAsListen(t *testing.T) {
|
||||
scrobble := maloja.Scrobble{
|
||||
ListenedAt: 1699289873,
|
||||
Track: maloja.Track{
|
||||
|
@ -45,7 +45,7 @@ func TestScrobbleToListen(t *testing.T) {
|
|||
},
|
||||
Origin: "client:Funkwhale",
|
||||
}
|
||||
listen := scrobble.ToListen()
|
||||
listen := scrobble.AsListen()
|
||||
assert := assert.New(t)
|
||||
assert.Equal(time.Unix(1699289873, 0), listen.ListenedAt)
|
||||
assert.Equal(time.Duration(414*time.Second), listen.Duration)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue