Skip to content

Commit

Permalink
fix: show artist album count when searching by tags
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Nov 10, 2021
1 parent 48c34fd commit 0c79044
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions server/ctrlsubsonic/handlers_by_tags.go
Expand Up @@ -185,13 +185,14 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
// search "artists"
var artists []*db.Artist
q := c.DB.
Select("*, count(albums.id) album_count").
Group("artists.id").
Where("name LIKE ? OR name_u_dec LIKE ?", query, query).
Joins("JOIN albums ON albums.tag_artist_id=artists.id").
Offset(params.GetOrInt("artistOffset", 0)).
Limit(params.GetOrInt("artistCount", 20))
if m := c.getMusicFolder(params); m != "" {
q = q.
Joins("JOIN albums ON albums.tag_artist_id=artists.id").
Where("albums.root_dir=?", m)
q = q.Where("albums.root_dir=?", m)
}
if err := q.Find(&artists).Error; err != nil {
return spec.NewError(0, "find artists: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions server/ctrlsubsonic/testdata/test_search_three_q_art
Expand Up @@ -5,9 +5,9 @@
"type": "gonic",
"searchResult3": {
"artist": [
{ "id": "ar-1", "name": "artist-0", "albumCount": 0 },
{ "id": "ar-2", "name": "artist-1", "albumCount": 0 },
{ "id": "ar-3", "name": "artist-2", "albumCount": 0 }
{ "id": "ar-1", "name": "artist-0", "albumCount": 3 },
{ "id": "ar-2", "name": "artist-1", "albumCount": 3 },
{ "id": "ar-3", "name": "artist-2", "albumCount": 3 }
]
}
}
Expand Down

0 comments on commit 0c79044

Please sign in to comment.