From 1a1f39f4e8e5553f32499b1461d227a93820e70f Mon Sep 17 00:00:00 2001 From: sentriz Date: Thu, 21 Jul 2022 19:52:05 +0100 Subject: [PATCH] fix(subsonic): return song artist ID, album and song genres from search3 related: #229 --- server/ctrlsubsonic/handlers_by_tags.go | 7 +++- .../testdata/test_search_three_q_alb | 9 +++++ .../testdata/test_search_three_q_tra | 40 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/server/ctrlsubsonic/handlers_by_tags.go b/server/ctrlsubsonic/handlers_by_tags.go index c234ffc6..e1025b41 100644 --- a/server/ctrlsubsonic/handlers_by_tags.go +++ b/server/ctrlsubsonic/handlers_by_tags.go @@ -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 { @@ -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)) @@ -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)) diff --git a/server/ctrlsubsonic/testdata/test_search_three_q_alb b/server/ctrlsubsonic/testdata/test_search_three_q_alb index e0b20242..375d8b29 100644 --- a/server/ctrlsubsonic/testdata/test_search_three_q_alb +++ b/server/ctrlsubsonic/testdata/test_search_three_q_alb @@ -16,6 +16,7 @@ "name": "album-0", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 }, { @@ -29,6 +30,7 @@ "name": "album-1", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 }, { @@ -42,6 +44,7 @@ "name": "album-2", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 }, { @@ -55,6 +58,7 @@ "name": "album-0", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 }, { @@ -68,6 +72,7 @@ "name": "album-1", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 }, { @@ -81,6 +86,7 @@ "name": "album-2", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 }, { @@ -94,6 +100,7 @@ "name": "album-0", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 }, { @@ -107,6 +114,7 @@ "name": "album-1", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 }, { @@ -120,6 +128,7 @@ "name": "album-2", "songCount": 0, "duration": 0, + "genre": "Unknown Genre", "year": 2021 } ] diff --git a/server/ctrlsubsonic/testdata/test_search_three_q_tra b/server/ctrlsubsonic/testdata/test_search_three_q_tra index 11b79de7..92e98c1f 100644 --- a/server/ctrlsubsonic/testdata/test_search_three_q_tra +++ b/server/ctrlsubsonic/testdata/test_search_three_q_tra @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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",