Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(subsonic): return song artist ID, album and song genres from search3
related: #229
  • Loading branch information
sentriz committed Jul 21, 2022
1 parent 4557a4e commit 1a1f39f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/ctrlsubsonic/handlers_by_tags.go
Expand Up @@ -10,11 +10,11 @@ import (

"github.com/jinzhu/gorm"

"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/scrobble/lastfm"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/scrobble/lastfm"
)

func (c *Controller) ServeGetArtists(r *http.Request) *spec.Response {
Expand Down Expand Up @@ -211,6 +211,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
var albums []*db.Album
q = c.DB.
Preload("TagArtist").
Preload("Genres").
Where("tag_title LIKE ? OR tag_title_u_dec LIKE ?", query, query).
Offset(params.GetOrInt("albumOffset", 0)).
Limit(params.GetOrInt("albumCount", 20))
Expand All @@ -228,6 +229,8 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
var tracks []*db.Track
q = c.DB.
Preload("Album").
Preload("Album.TagArtist").
Preload("Genres").
Where("tag_title LIKE ? OR tag_title_u_dec LIKE ?", query, query).
Offset(params.GetOrInt("songOffset", 0)).
Limit(params.GetOrInt("songCount", 20))
Expand Down
9 changes: 9 additions & 0 deletions server/ctrlsubsonic/testdata/test_search_three_q_alb
Expand Up @@ -16,6 +16,7 @@
"name": "album-0",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
},
{
Expand All @@ -29,6 +30,7 @@
"name": "album-1",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
},
{
Expand All @@ -42,6 +44,7 @@
"name": "album-2",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
},
{
Expand All @@ -55,6 +58,7 @@
"name": "album-0",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
},
{
Expand All @@ -68,6 +72,7 @@
"name": "album-1",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
},
{
Expand All @@ -81,6 +86,7 @@
"name": "album-2",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
},
{
Expand All @@ -94,6 +100,7 @@
"name": "album-0",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
},
{
Expand All @@ -107,6 +114,7 @@
"name": "album-1",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
},
{
Expand All @@ -120,6 +128,7 @@
"name": "album-2",
"songCount": 0,
"duration": 0,
"genre": "Unknown Genre",
"year": 2021
}
]
Expand Down
40 changes: 40 additions & 0 deletions server/ctrlsubsonic/testdata/test_search_three_q_tra
Expand Up @@ -10,11 +10,13 @@
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-3",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-3",
Expand All @@ -31,11 +33,13 @@
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-3",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-3",
Expand All @@ -52,11 +56,13 @@
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-3",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-3",
Expand All @@ -73,11 +79,13 @@
"album": "album-1",
"albumId": "al-4",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-4",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-4",
Expand All @@ -94,11 +102,13 @@
"album": "album-1",
"albumId": "al-4",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-4",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-4",
Expand All @@ -115,11 +125,13 @@
"album": "album-1",
"albumId": "al-4",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-4",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-4",
Expand All @@ -136,11 +148,13 @@
"album": "album-2",
"albumId": "al-5",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-5",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-5",
Expand All @@ -157,11 +171,13 @@
"album": "album-2",
"albumId": "al-5",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-5",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-5",
Expand All @@ -178,11 +194,13 @@
"album": "album-2",
"albumId": "al-5",
"artist": "artist-0",
"artistId": "ar-1",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-5",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-5",
Expand All @@ -199,11 +217,13 @@
"album": "album-0",
"albumId": "al-7",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-7",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-7",
Expand All @@ -220,11 +240,13 @@
"album": "album-0",
"albumId": "al-7",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-7",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-7",
Expand All @@ -241,11 +263,13 @@
"album": "album-0",
"albumId": "al-7",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-7",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-7",
Expand All @@ -262,11 +286,13 @@
"album": "album-1",
"albumId": "al-8",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-8",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-8",
Expand All @@ -283,11 +309,13 @@
"album": "album-1",
"albumId": "al-8",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-8",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-8",
Expand All @@ -304,11 +332,13 @@
"album": "album-1",
"albumId": "al-8",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-8",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-8",
Expand All @@ -325,11 +355,13 @@
"album": "album-2",
"albumId": "al-9",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-9",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-9",
Expand All @@ -346,11 +378,13 @@
"album": "album-2",
"albumId": "al-9",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-9",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-9",
Expand All @@ -367,11 +401,13 @@
"album": "album-2",
"albumId": "al-9",
"artist": "artist-1",
"artistId": "ar-2",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-9",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-9",
Expand All @@ -388,11 +424,13 @@
"album": "album-0",
"albumId": "al-11",
"artist": "artist-2",
"artistId": "ar-3",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-11",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-11",
Expand All @@ -409,11 +447,13 @@
"album": "album-0",
"albumId": "al-11",
"artist": "artist-2",
"artistId": "ar-3",
"bitRate": 100,
"contentType": "audio/x-flac",
"coverArt": "al-11",
"created": "2019-11-30T00:00:00Z",
"duration": 100,
"genre": "Unknown Genre",
"isDir": false,
"isVideo": false,
"parent": "al-11",
Expand Down

0 comments on commit 1a1f39f

Please sign in to comment.