mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-30 15:19:21 +03:00
Indexes using slices instead of pointers of slice
This commit is contained in:
parent
27b7b7ce08
commit
3f0030738a
@ -47,8 +47,8 @@ func (c *BrowsingController) GetIndexes() {
|
||||
LastModified: fmt.Sprint(utils.ToMillis(lastModified)),
|
||||
}
|
||||
|
||||
res.Index = make([]responses.Index, len(*indexes))
|
||||
for i, idx := range *indexes {
|
||||
res.Index = make([]responses.Index, len(indexes))
|
||||
for i, idx := range indexes {
|
||||
res.Index[i].Name = idx.Id
|
||||
res.Index[i].Artists = make([]responses.Artist, len(idx.Artists))
|
||||
for j, a := range idx.Artists {
|
||||
|
@ -26,5 +26,5 @@ type ArtistIndexRepository interface {
|
||||
BaseRepository
|
||||
Put(m *ArtistIndex) error
|
||||
Get(id string) (*ArtistIndex, error)
|
||||
GetAll() (*ArtistIndexes, error)
|
||||
GetAll() (ArtistIndexes, error)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
|
||||
type Browser interface {
|
||||
MediaFolders() (*domain.MediaFolders, error)
|
||||
Indexes(ifModifiedSince time.Time) (*domain.ArtistIndexes, time.Time, error)
|
||||
Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time.Time, error)
|
||||
Directory(id string) (*DirectoryInfo, error)
|
||||
}
|
||||
|
||||
@ -36,13 +36,13 @@ func (b browser) MediaFolders() (*domain.MediaFolders, error) {
|
||||
return b.folderRepo.GetAll()
|
||||
}
|
||||
|
||||
func (b browser) Indexes(ifModifiedSince time.Time) (*domain.ArtistIndexes, time.Time, error) {
|
||||
func (b browser) Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time.Time, error) {
|
||||
l, err := b.propRepo.DefaultGet(consts.LastScan, "-1")
|
||||
ms, _ := strconv.ParseInt(l, 10, 64)
|
||||
lastModified := utils.ToTime(ms)
|
||||
|
||||
if err != nil {
|
||||
return &domain.ArtistIndexes{}, time.Time{}, errors.New(fmt.Sprintf("Error retrieving LastScan property: %v", err))
|
||||
return nil, time.Time{}, errors.New(fmt.Sprintf("Error retrieving LastScan property: %v", err))
|
||||
}
|
||||
|
||||
if lastModified.After(ifModifiedSince) {
|
||||
@ -50,7 +50,7 @@ func (b browser) Indexes(ifModifiedSince time.Time) (*domain.ArtistIndexes, time
|
||||
return indexes, lastModified, err
|
||||
}
|
||||
|
||||
return &domain.ArtistIndexes{}, lastModified, nil
|
||||
return nil, lastModified, nil
|
||||
}
|
||||
|
||||
type DirectoryInfo struct {
|
||||
|
@ -31,10 +31,10 @@ func (r *artistIndexRepository) Get(id string) (*domain.ArtistIndex, error) {
|
||||
return rec.(*domain.ArtistIndex), err
|
||||
}
|
||||
|
||||
func (r *artistIndexRepository) GetAll() (*domain.ArtistIndexes, error) {
|
||||
func (r *artistIndexRepository) GetAll() (domain.ArtistIndexes, error) {
|
||||
var indices = make(domain.ArtistIndexes, 0)
|
||||
err := r.loadAll(&indices, domain.QueryOptions{Alpha: true})
|
||||
return &indices, err
|
||||
return indices, err
|
||||
}
|
||||
|
||||
var _ domain.ArtistIndexRepository = (*artistIndexRepository)(nil)
|
||||
|
@ -57,7 +57,7 @@ func TestIndexRepository(t *testing.T) {
|
||||
So(indices, ShouldHaveLength, 4)
|
||||
})
|
||||
Convey("And the values should be retrieved", func() {
|
||||
for _, e := range *indices {
|
||||
for _, e := range indices {
|
||||
So(e.Id, ShouldBeIn, []string{"1", "2", "3", "4"})
|
||||
}
|
||||
})
|
||||
|
@ -30,9 +30,9 @@ func (m *MockArtistIndex) SetData(j string, length int) {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockArtistIndex) GetAll() (*domain.ArtistIndexes, error) {
|
||||
func (m *MockArtistIndex) GetAll() (domain.ArtistIndexes, error) {
|
||||
if m.err {
|
||||
return nil, errors.New("Error!")
|
||||
}
|
||||
return &m.data, nil
|
||||
return m.data, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user