mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 13:07:36 +03:00
Removed Playlist.GetWithTracks, not needed anymore
This commit is contained in:
parent
e232c5c561
commit
9fb4f5ef52
4 changed files with 10 additions and 27 deletions
|
@ -124,7 +124,7 @@ type PlaylistInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *playlists) Get(ctx context.Context, id string) (*PlaylistInfo, error) {
|
func (p *playlists) Get(ctx context.Context, id string) (*PlaylistInfo, error) {
|
||||||
pl, err := p.ds.Playlist(ctx).GetWithTracks(id)
|
pl, err := p.ds.Playlist(ctx).Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ type PlaylistRepository interface {
|
||||||
Exists(id string) (bool, error)
|
Exists(id string) (bool, error)
|
||||||
Put(pls *Playlist) error
|
Put(pls *Playlist) error
|
||||||
Get(id string) (*Playlist, error)
|
Get(id string) (*Playlist, error)
|
||||||
GetWithTracks(id string) (*Playlist, error)
|
|
||||||
GetAll(options ...QueryOptions) (Playlists, error)
|
GetAll(options ...QueryOptions) (Playlists, error)
|
||||||
Delete(id string) error
|
Delete(id string) error
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,19 +65,6 @@ func (r *playlistRepository) Get(id string) (*model.Playlist, error) {
|
||||||
return &pls, err
|
return &pls, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *playlistRepository) GetWithTracks(id string) (*model.Playlist, error) {
|
|
||||||
pls, err := r.Get(id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
pls.Duration = 0
|
|
||||||
pls.Tracks = r.loadTracks(pls)
|
|
||||||
for _, t := range pls.Tracks {
|
|
||||||
pls.Duration += t.Duration
|
|
||||||
}
|
|
||||||
return pls, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *playlistRepository) GetAll(options ...model.QueryOptions) (model.Playlists, error) {
|
func (r *playlistRepository) GetAll(options ...model.QueryOptions) (model.Playlists, error) {
|
||||||
sel := r.newSelect(options...).Columns("*")
|
sel := r.newSelect(options...).Columns("*")
|
||||||
var res []playlist
|
var res []playlist
|
||||||
|
|
|
@ -49,6 +49,15 @@ var _ = Describe("PlaylistRepository", func() {
|
||||||
_, err := repo.Get("666")
|
_, err := repo.Get("666")
|
||||||
Expect(err).To(MatchError(model.ErrNotFound))
|
Expect(err).To(MatchError(model.ErrNotFound))
|
||||||
})
|
})
|
||||||
|
It("returns all tracks", func() {
|
||||||
|
pls, err := repo.Get("10")
|
||||||
|
Expect(err).To(BeNil())
|
||||||
|
Expect(pls.Name).To(Equal(plsBest.Name))
|
||||||
|
Expect(pls.Tracks).To(Equal(model.MediaFiles{
|
||||||
|
songDayInALife,
|
||||||
|
songRadioactivity,
|
||||||
|
}))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Put/Exists/Delete", func() {
|
Describe("Put/Exists/Delete", func() {
|
||||||
|
@ -70,18 +79,6 @@ var _ = Describe("PlaylistRepository", func() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("GetWithTracks", func() {
|
|
||||||
It("returns an existing playlist", func() {
|
|
||||||
pls, err := repo.GetWithTracks("10")
|
|
||||||
Expect(err).To(BeNil())
|
|
||||||
Expect(pls.Name).To(Equal(plsBest.Name))
|
|
||||||
Expect(pls.Tracks).To(Equal(model.MediaFiles{
|
|
||||||
songDayInALife,
|
|
||||||
songRadioactivity,
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
Describe("GetAll", func() {
|
Describe("GetAll", func() {
|
||||||
It("returns all playlists from DB", func() {
|
It("returns all playlists from DB", func() {
|
||||||
all, err := repo.GetAll()
|
all, err := repo.GetAll()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue