mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-23 23:20:57 +03:00
refactor: add search back to albums and artists
This commit is contained in:
parent
d755609d13
commit
5a4c763510
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user