This commit is contained in:
Deluan 2020-10-21 17:31:46 -04:00
parent 62ed30afed
commit b88f9013dc
2 changed files with 9 additions and 4 deletions

View file

@ -21,7 +21,7 @@ func NewAlbumListController(listGen engine.ListGenerator) *AlbumListController {
return c return c
} }
func (c *AlbumListController) getNewAlbumList(r *http.Request) (engine.Entries, error) { func (c *AlbumListController) getAlbumList(r *http.Request) (engine.Entries, error) {
typ, err := requiredParamString(r, "type", "Required string parameter 'type' is not present") typ, err := requiredParamString(r, "type", "Required string parameter 'type' is not present")
if err != nil { if err != nil {
return nil, err return nil, err
@ -67,7 +67,7 @@ func (c *AlbumListController) getNewAlbumList(r *http.Request) (engine.Entries,
} }
func (c *AlbumListController) GetAlbumList(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) { func (c *AlbumListController) GetAlbumList(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
albums, err := c.getNewAlbumList(r) albums, err := c.getAlbumList(r)
if err != nil { if err != nil {
return nil, newError(responses.ErrorGeneric, err.Error()) return nil, newError(responses.ErrorGeneric, err.Error())
} }
@ -78,7 +78,7 @@ func (c *AlbumListController) GetAlbumList(w http.ResponseWriter, r *http.Reques
} }
func (c *AlbumListController) GetAlbumList2(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) { func (c *AlbumListController) GetAlbumList2(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
albums, err := c.getNewAlbumList(r) albums, err := c.getAlbumList(r)
if err != nil { if err != nil {
return nil, newError(responses.ErrorGeneric, err.Error()) return nil, newError(responses.ErrorGeneric, err.Error())
} }

View file

@ -61,8 +61,13 @@ func ByGenre(genre string) ListFilter {
} }
func ByYear(fromYear, toYear int) ListFilter { func ByYear(fromYear, toYear int) ListFilter {
sortOption := "max_year, name"
if fromYear > toYear {
fromYear, toYear = toYear, fromYear
sortOption = "max_year desc, name"
}
return ListFilter{ return ListFilter{
Sort: "max_year, name", Sort: sortOption,
Filters: squirrel.Or{ Filters: squirrel.Or{
squirrel.And{ squirrel.And{
squirrel.GtOrEq{"min_year": fromYear}, squirrel.GtOrEq{"min_year": fromYear},