Optimize AlbumRepository.GetAll and add a GetAllWithoutGenres method specifically for Subsonic API, where multiple-genres are not required

This commit is contained in:
Deluan
2021-11-02 21:18:53 -04:00
parent bc8132ef1f
commit 9422373be0
6 changed files with 33 additions and 9 deletions
+2 -2
View File
@@ -63,7 +63,7 @@ func (c *AlbumListController) getAlbumList(r *http.Request) (model.Albums, int64
opts.Offset = utils.ParamInt(r, "offset", 0)
opts.Max = utils.MinInt(utils.ParamInt(r, "size", 10), 500)
albums, err := c.ds.Album(r.Context()).GetAll(opts)
albums, err := c.ds.Album(r.Context()).GetAllWithoutGenres(opts)
if err != nil {
log.Error(r, "Error retrieving albums", "error", err)
@@ -113,7 +113,7 @@ func (c *AlbumListController) GetStarred(w http.ResponseWriter, r *http.Request)
log.Error(r, "Error retrieving starred artists", "error", err)
return nil, err
}
albums, err := c.ds.Album(ctx).GetAll(options)
albums, err := c.ds.Album(ctx).GetAllWithoutGenres(options)
if err != nil {
log.Error(r, "Error retrieving starred albums", "error", err)
return nil, err
+2 -2
View File
@@ -149,7 +149,7 @@ func (c *BrowsingController) GetArtist(w http.ResponseWriter, r *http.Request) (
return nil, err
}
albums, err := c.ds.Album(ctx).GetAll(filter.AlbumsByArtistID(id))
albums, err := c.ds.Album(ctx).GetAllWithoutGenres(filter.AlbumsByArtistID(id))
if err != nil {
log.Error(ctx, "Error retrieving albums by artist", "id", id, "name", artist.Name, err)
return nil, err
@@ -337,7 +337,7 @@ func (c *BrowsingController) buildArtistDirectory(ctx context.Context, artist *m
dir.Starred = &artist.StarredAt
}
albums, err := c.ds.Album(ctx).GetAll(filter.AlbumsByArtistID(artist.ID))
albums, err := c.ds.Album(ctx).GetAllWithoutGenres(filter.AlbumsByArtistID(artist.ID))
if err != nil {
return nil, err
}