Remove tracks from Playlist's GetAll

This commit is contained in:
Deluan 2020-05-11 10:53:09 -04:00 committed by Deluan Quintão
parent ab690215ef
commit 5682d0e721
2 changed files with 1 additions and 15 deletions

View file

@ -14,7 +14,7 @@ type Playlist struct {
SongCount int `json:"songCount"` SongCount int `json:"songCount"`
Owner string `json:"owner"` Owner string `json:"owner"`
Public bool `json:"public"` Public bool `json:"public"`
Tracks MediaFiles `json:"tracks"` Tracks MediaFiles `json:"tracks,omitempty"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
} }

View file

@ -74,11 +74,6 @@ func (r *playlistRepository) GetAll(options ...model.QueryOptions) (model.Playli
sel := r.newSelect(options...).Columns("*") sel := r.newSelect(options...).Columns("*")
var res model.Playlists var res model.Playlists
err := r.queryAll(sel, &res) err := r.queryAll(sel, &res)
if err != nil {
return nil, err
}
// TODO Maybe the tracks are not required when retrieving all playlists?
err = r.loadAllTracks(res)
return res, err return res, err
} }
@ -128,15 +123,6 @@ func (r *playlistRepository) updateTracks(id string, tracks model.MediaFiles) er
return err return err
} }
func (r *playlistRepository) loadAllTracks(all model.Playlists) error {
for i := range all {
if err := r.loadTracks(&all[i]); err != nil {
return err
}
}
return nil
}
func (r *playlistRepository) loadTracks(pls *model.Playlist) (err error) { func (r *playlistRepository) loadTracks(pls *model.Playlist) (err error) {
tracksQuery := Select().From("playlist_tracks"). tracksQuery := Select().From("playlist_tracks").
LeftJoin("annotation on ("+ LeftJoin("annotation on ("+