Implemented getAlbumList with type=random
This commit is contained in:
@@ -41,8 +41,24 @@ func (r *albumRepository) GetAll(options domain.QueryOptions) (*domain.Albums, e
|
||||
return &as, err
|
||||
}
|
||||
|
||||
func (r *albumRepository) GetAllIds() (*[]string, error) {
|
||||
idMap, err := r.getAllIds()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids := make([]string, len(idMap))
|
||||
|
||||
i := 0
|
||||
for id, _ := range idMap {
|
||||
ids[i] = id
|
||||
i++
|
||||
}
|
||||
|
||||
return &ids, nil
|
||||
}
|
||||
|
||||
func (r *albumRepository) PurgeInactive(active *domain.Albums) error {
|
||||
currentIds, err := r.GetAllIds()
|
||||
currentIds, err := r.getAllIds()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func (r *artistRepository) GetByName(name string) (*domain.Artist, error) {
|
||||
}
|
||||
|
||||
func (r *artistRepository) PurgeInactive(active *domain.Artists) error {
|
||||
currentIds, err := r.GetAllIds()
|
||||
currentIds, err := r.getAllIds()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func (r *ledisRepository) CountAll() (int64, error) {
|
||||
return size, err
|
||||
}
|
||||
|
||||
func (r *ledisRepository) GetAllIds() (map[string]bool, error) {
|
||||
func (r *ledisRepository) getAllIds() (map[string]bool, error) {
|
||||
m := make(map[string]bool)
|
||||
pairs, err := db().ZRange([]byte(r.table+"s:all"), 0, -1)
|
||||
if err != nil {
|
||||
|
||||
@@ -155,7 +155,7 @@ func TestBaseRepository(t *testing.T) {
|
||||
})
|
||||
})
|
||||
Convey("When I call GetAllIds", func() {
|
||||
ids, err := repo.GetAllIds()
|
||||
ids, err := repo.getAllIds()
|
||||
Convey("Then It should not return any error", func() {
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
@@ -44,7 +44,7 @@ func (r *mediaFileRepository) FindByAlbum(albumId string) (*domain.MediaFiles, e
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) PurgeInactive(active *domain.MediaFiles) error {
|
||||
currentIds, err := r.GetAllIds()
|
||||
currentIds, err := r.getAllIds()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user