Update ServeGetAlbumList to reflect @Duncaen's changes

This commit is contained in:
sentriz
2020-07-24 14:29:02 +01:00
parent 365bfa9c59
commit f16f07b8a8
2 changed files with 2 additions and 1 deletions

View File

@@ -131,7 +131,7 @@ func (c *Controller) ServeGetAlbumList(r *http.Request) *spec.Response {
// TODO: think about removing this extra join to count number
// of children. it might make sense to store that in the db
q.
Select("albums.*, count(tracks.id) child_count").
Select("albums.*, count(tracks.id) child_count, sum(tracks.length) duration").
Joins("LEFT JOIN tracks ON tracks.album_id=albums.id").
Group("albums.id").
Where("albums.tag_artist_id IS NOT NULL").

View File

@@ -14,6 +14,7 @@ func NewAlbumByFolder(f *db.Album) *Album {
ParentID: f.ParentSID(),
Title: f.RightPath,
TrackCount: f.ChildCount,
Duration: f.Duration,
}
if f.Cover != "" {
a.CoverID = f.SID()