diff --git a/server/ctrlsubsonic/handlers_by_folder.go b/server/ctrlsubsonic/handlers_by_folder.go index 2f20017..2b3d85f 100644 --- a/server/ctrlsubsonic/handlers_by_folder.go +++ b/server/ctrlsubsonic/handlers_by_folder.go @@ -80,11 +80,13 @@ func (c *Controller) ServeGetMusicDirectory(r *http.Request) *spec.Response { Where("parent_id=?", id.Value). Preload("AlbumStar", "user_id=?", user.ID). Preload("AlbumRating", "user_id=?", user.ID). + Order("tag_year"). Order("albums.right_path COLLATE NOCASE"). Find(&childFolders) for _, ch := range childFolders { childrenObj = append(childrenObj, spec.NewTCAlbumByFolder(ch)) } + // start looking for child childTracks in the current dir var childTracks []*db.Track c.dbc. @@ -94,6 +96,7 @@ func (c *Controller) ServeGetMusicDirectory(r *http.Request) *spec.Response { Preload("Artists"). Preload("TrackStar", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID). + Order("tag_track_number"). Order("filename"). Find(&childTracks) diff --git a/server/ctrlsubsonic/spec/construct_by_folder.go b/server/ctrlsubsonic/spec/construct_by_folder.go index f8f35d3..c39b695 100644 --- a/server/ctrlsubsonic/spec/construct_by_folder.go +++ b/server/ctrlsubsonic/spec/construct_by_folder.go @@ -40,6 +40,7 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild { ParentID: f.ParentSID(), CreatedAt: f.CreatedAt, AverageRating: formatRating(f.AverageRating), + Year: f.TagYear, } if f.AlbumStar != nil { trCh.Starred = &f.AlbumStar.StarDate diff --git a/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks b/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks index b4a9721..83b3b0e 100644 --- a/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks +++ b/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks @@ -23,6 +23,7 @@ "isVideo": false, "parent": "al-2", "title": "album-0", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -39,6 +40,7 @@ "isVideo": false, "parent": "al-2", "title": "album-1", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -55,6 +57,7 @@ "isVideo": false, "parent": "al-2", "title": "album-2", + "year": 2021, "musicBrainzId": "", "replayGain": null } diff --git a/server/ctrlsubsonic/testdata/test_search_two_q_alb b/server/ctrlsubsonic/testdata/test_search_two_q_alb index 3c449b6..9f1dfa0 100644 --- a/server/ctrlsubsonic/testdata/test_search_two_q_alb +++ b/server/ctrlsubsonic/testdata/test_search_two_q_alb @@ -20,6 +20,7 @@ "isVideo": false, "parent": "al-2", "title": "album-0", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -36,6 +37,7 @@ "isVideo": false, "parent": "al-2", "title": "album-1", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -52,6 +54,7 @@ "isVideo": false, "parent": "al-2", "title": "album-2", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -68,6 +71,7 @@ "isVideo": false, "parent": "al-6", "title": "album-0", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -84,6 +88,7 @@ "isVideo": false, "parent": "al-6", "title": "album-1", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -100,6 +105,7 @@ "isVideo": false, "parent": "al-6", "title": "album-2", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -116,6 +122,7 @@ "isVideo": false, "parent": "al-10", "title": "album-0", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -132,6 +139,7 @@ "isVideo": false, "parent": "al-10", "title": "album-1", + "year": 2021, "musicBrainzId": "", "replayGain": null }, @@ -148,6 +156,7 @@ "isVideo": false, "parent": "al-10", "title": "album-2", + "year": 2021, "musicBrainzId": "", "replayGain": null }