More Album List types
This commit is contained in:
parent
5dd4b15079
commit
12b1002d51
|
@ -19,11 +19,14 @@ func (c *AlbumListController) Prepare() {
|
||||||
utils.ResolveDependencies(&c.listGen)
|
utils.ResolveDependencies(&c.listGen)
|
||||||
|
|
||||||
c.types = map[string]strategy{
|
c.types = map[string]strategy{
|
||||||
"random": func(o int, s int) (engine.Entries, error) { return c.listGen.GetRandom(o, s) },
|
"random": func(o int, s int) (engine.Entries, error) { return c.listGen.GetRandom(o, s) },
|
||||||
"newest": func(o int, s int) (engine.Entries, error) { return c.listGen.GetNewest(o, s) },
|
"newest": func(o int, s int) (engine.Entries, error) { return c.listGen.GetNewest(o, s) },
|
||||||
"recent": func(o int, s int) (engine.Entries, error) { return c.listGen.GetRecent(o, s) },
|
"recent": func(o int, s int) (engine.Entries, error) { return c.listGen.GetRecent(o, s) },
|
||||||
"frequent": func(o int, s int) (engine.Entries, error) { return c.listGen.GetFrequent(o, s) },
|
"frequent": func(o int, s int) (engine.Entries, error) { return c.listGen.GetFrequent(o, s) },
|
||||||
"highest": func(o int, s int) (engine.Entries, error) { return c.listGen.GetHighest(o, s) },
|
"highest": func(o int, s int) (engine.Entries, error) { return c.listGen.GetHighest(o, s) },
|
||||||
|
"alphabeticalByName": func(o int, s int) (engine.Entries, error) { return c.listGen.GetByName(o, s) },
|
||||||
|
"alphabeticalByArtist": func(o int, s int) (engine.Entries, error) { return c.listGen.GetByArtist(o, s) },
|
||||||
|
"starred": func(o int, s int) (engine.Entries, error) { return c.listGen.GetStarred(o, s) },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ func (c *AlbumListController) GetAlbumList() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AlbumListController) GetStarred() {
|
func (c *AlbumListController) GetStarred() {
|
||||||
albums, err := c.listGen.GetStarred()
|
albums, err := c.listGen.GetStarred(0, -1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beego.Error("Error retrieving starred albums:", err)
|
beego.Error("Error retrieving starred albums:", err)
|
||||||
c.SendError(responses.ERROR_GENERIC, "Internal Error")
|
c.SendError(responses.ERROR_GENERIC, "Internal Error")
|
|
@ -14,7 +14,9 @@ type ListGenerator interface {
|
||||||
GetFrequent(offset int, size int) (Entries, error)
|
GetFrequent(offset int, size int) (Entries, error)
|
||||||
GetHighest(offset int, size int) (Entries, error)
|
GetHighest(offset int, size int) (Entries, error)
|
||||||
GetRandom(offset int, size int) (Entries, error)
|
GetRandom(offset int, size int) (Entries, error)
|
||||||
GetStarred() (Entries, error)
|
GetByName(offset int, size int) (Entries, error)
|
||||||
|
GetByArtist(offset int, size int) (Entries, error)
|
||||||
|
GetStarred(offset int, size int) (Entries, error)
|
||||||
GetNowPlaying() (Entries, error)
|
GetNowPlaying() (Entries, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +58,16 @@ func (g listGenerator) GetHighest(offset int, size int) (Entries, error) {
|
||||||
return g.query(qo, offset, size)
|
return g.query(qo, offset, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g listGenerator) GetByName(offset int, size int) (Entries, error) {
|
||||||
|
qo := domain.QueryOptions{SortBy: "Name", Alpha: true}
|
||||||
|
return g.query(qo, offset, size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g listGenerator) GetByArtist(offset int, size int) (Entries, error) {
|
||||||
|
qo := domain.QueryOptions{SortBy: "Artist", Alpha: true}
|
||||||
|
return g.query(qo, offset, size)
|
||||||
|
}
|
||||||
|
|
||||||
func (g listGenerator) GetRandom(offset int, size int) (Entries, error) {
|
func (g listGenerator) GetRandom(offset int, size int) (Entries, error) {
|
||||||
ids, err := g.albumRepo.GetAllIds()
|
ids, err := g.albumRepo.GetAllIds()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -76,8 +88,9 @@ func (g listGenerator) GetRandom(offset int, size int) (Entries, error) {
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g listGenerator) GetStarred() (Entries, error) {
|
func (g listGenerator) GetStarred(offset int, size int) (Entries, error) {
|
||||||
albums, err := g.albumRepo.GetStarred(domain.QueryOptions{})
|
qo := domain.QueryOptions{Offset: offset, Size: size}
|
||||||
|
albums, err := g.albumRepo.GetStarred(qo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue