Implemented getAlbumList with type=random

This commit is contained in:
Deluan
2016-03-08 21:54:32 -05:00
parent 867ca0580c
commit 9bea04f330
8 changed files with 44 additions and 5 deletions
+17 -1
View File
@@ -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
}
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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)
})
+1 -1
View File
@@ -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
}