Skip to content

Commit 39df00e

Browse files
mikuta0407sentriz
authored andcommitted
fix(subsonic): order some browse-by-tag responses
closes #512
1 parent 5c7d065 commit 39df00e

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

server/ctrlsubsonic/handlers_by_folder.go

+3
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ func (c *Controller) ServeGetMusicDirectory(r *http.Request) *spec.Response {
8080
Where("parent_id=?", id.Value).
8181
Preload("AlbumStar", "user_id=?", user.ID).
8282
Preload("AlbumRating", "user_id=?", user.ID).
83+
Order("tag_year").
8384
Order("albums.right_path COLLATE NOCASE").
8485
Find(&childFolders)
8586
for _, ch := range childFolders {
8687
childrenObj = append(childrenObj, spec.NewTCAlbumByFolder(ch))
8788
}
89+
8890
// start looking for child childTracks in the current dir
8991
var childTracks []*db.Track
9092
c.dbc.
@@ -94,6 +96,7 @@ func (c *Controller) ServeGetMusicDirectory(r *http.Request) *spec.Response {
9496
Preload("Artists").
9597
Preload("TrackStar", "user_id=?", user.ID).
9698
Preload("TrackRating", "user_id=?", user.ID).
99+
Order("tag_track_number").
97100
Order("filename").
98101
Find(&childTracks)
99102

server/ctrlsubsonic/spec/construct_by_folder.go

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild {
4040
ParentID: f.ParentSID(),
4141
CreatedAt: f.CreatedAt,
4242
AverageRating: formatRating(f.AverageRating),
43+
Year: f.TagYear,
4344
}
4445
if f.AlbumStar != nil {
4546
trCh.Starred = &f.AlbumStar.StarDate

server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"isVideo": false,
2424
"parent": "al-2",
2525
"title": "album-0",
26+
"year": 2021,
2627
"musicBrainzId": "",
2728
"replayGain": null
2829
},
@@ -39,6 +40,7 @@
3940
"isVideo": false,
4041
"parent": "al-2",
4142
"title": "album-1",
43+
"year": 2021,
4244
"musicBrainzId": "",
4345
"replayGain": null
4446
},
@@ -55,6 +57,7 @@
5557
"isVideo": false,
5658
"parent": "al-2",
5759
"title": "album-2",
60+
"year": 2021,
5861
"musicBrainzId": "",
5962
"replayGain": null
6063
}

server/ctrlsubsonic/testdata/test_search_two_q_alb

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"isVideo": false,
2121
"parent": "al-2",
2222
"title": "album-0",
23+
"year": 2021,
2324
"musicBrainzId": "",
2425
"replayGain": null
2526
},
@@ -36,6 +37,7 @@
3637
"isVideo": false,
3738
"parent": "al-2",
3839
"title": "album-1",
40+
"year": 2021,
3941
"musicBrainzId": "",
4042
"replayGain": null
4143
},
@@ -52,6 +54,7 @@
5254
"isVideo": false,
5355
"parent": "al-2",
5456
"title": "album-2",
57+
"year": 2021,
5558
"musicBrainzId": "",
5659
"replayGain": null
5760
},
@@ -68,6 +71,7 @@
6871
"isVideo": false,
6972
"parent": "al-6",
7073
"title": "album-0",
74+
"year": 2021,
7175
"musicBrainzId": "",
7276
"replayGain": null
7377
},
@@ -84,6 +88,7 @@
8488
"isVideo": false,
8589
"parent": "al-6",
8690
"title": "album-1",
91+
"year": 2021,
8792
"musicBrainzId": "",
8893
"replayGain": null
8994
},
@@ -100,6 +105,7 @@
100105
"isVideo": false,
101106
"parent": "al-6",
102107
"title": "album-2",
108+
"year": 2021,
103109
"musicBrainzId": "",
104110
"replayGain": null
105111
},
@@ -116,6 +122,7 @@
116122
"isVideo": false,
117123
"parent": "al-10",
118124
"title": "album-0",
125+
"year": 2021,
119126
"musicBrainzId": "",
120127
"replayGain": null
121128
},
@@ -132,6 +139,7 @@
132139
"isVideo": false,
133140
"parent": "al-10",
134141
"title": "album-1",
142+
"year": 2021,
135143
"musicBrainzId": "",
136144
"replayGain": null
137145
},
@@ -148,6 +156,7 @@
148156
"isVideo": false,
149157
"parent": "al-10",
150158
"title": "album-2",
159+
"year": 2021,
151160
"musicBrainzId": "",
152161
"replayGain": null
153162
}

0 commit comments

Comments
 (0)