diff --git a/persistence/album_repository.go b/persistence/album_repository.go index 8511106d7..577b04733 100644 --- a/persistence/album_repository.go +++ b/persistence/album_repository.go @@ -34,7 +34,10 @@ func (r *albumRepository) Exists(id string) (bool, error) { func (r *albumRepository) Put(a *model.Album) error { _, err := r.put(a.ID, a) - return err + if err != nil { + return err + } + return r.index(a.ID, a.Name) } func (r *albumRepository) selectAlbum(options ...model.QueryOptions) SelectBuilder { @@ -121,7 +124,6 @@ func (r *albumRepository) Refresh(ids ...string) error { } else { toInsert++ } - //err := r.addToIndex(r.tableName, al.ID, al.Name) TODO: Search err := r.Put(&al.Album) if err != nil { return err @@ -155,7 +157,9 @@ func (r *albumRepository) GetStarred(options ...model.QueryOptions) (model.Album } func (r *albumRepository) Search(q string, offset int, size int) (model.Albums, error) { - return nil, nil // TODO + var results model.Albums + err := r.doSearch(q, offset, size, &results, "name") + return results, err } func (r *albumRepository) Count(options ...rest.QueryOptions) (int64, error) { diff --git a/persistence/artist_repository.go b/persistence/artist_repository.go index 78bf5d146..516a1c616 100644 --- a/persistence/artist_repository.go +++ b/persistence/artist_repository.go @@ -54,7 +54,10 @@ func (r *artistRepository) getIndexKey(a *model.Artist) string { func (r *artistRepository) Put(a *model.Artist) error { _, err := r.put(a.ID, a) - return err + if err != nil { + return err + } + return r.index(a.ID, a.Name) } func (r *artistRepository) Get(id string) (*model.Artist, error) { @@ -140,7 +143,6 @@ where f.artist_id in ('%s') group by f.artist_id order by f.id`, strings.Join(id } else { toInsert++ } - //err := r.addToIndex(r.tableName, ar.ID, ar.Name) err := r.Put(&ar.Artist) if err != nil { return err @@ -165,11 +167,13 @@ func (r *artistRepository) PurgeEmpty() error { } func (r *artistRepository) Search(q string, offset int, size int) (model.Artists, error) { - return nil, nil // TODO + var results model.Artists + err := r.doSearch(q, offset, size, &results, "name") + return results, err } func (r *artistRepository) Count(options ...rest.QueryOptions) (int64, error) { - return r.CountAll(r.parseRestOptions(options...)) // TODO Don't apply pagination! + return r.CountAll(r.parseRestOptions(options...)) } func (r *artistRepository) Read(id string) (interface{}, error) { diff --git a/persistence/mediafile_repository.go b/persistence/mediafile_repository.go index 6e2e1e9c2..a600ea0ee 100644 --- a/persistence/mediafile_repository.go +++ b/persistence/mediafile_repository.go @@ -34,8 +34,7 @@ func (r mediaFileRepository) Put(m *model.MediaFile) error { if err != nil { return err } - r.index(m.ID, m.Title) - return nil + return r.index(m.ID, m.Title) } func (r mediaFileRepository) selectMediaFile(options ...model.QueryOptions) SelectBuilder {