mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-20 09:08:50 +01:00
Implement Album search with SQL
This commit is contained in:
parent
c2448d3880
commit
3a9559a860
4 changed files with 33 additions and 16 deletions
|
|
@ -108,20 +108,17 @@ func (s *search) SearchArtist(ctx context.Context, q string, offset int, size in
|
|||
|
||||
func (s *search) SearchAlbum(ctx context.Context, q string, offset int, size int) (Entries, error) {
|
||||
q = sanitize.Accents(strings.ToLower(strings.TrimSuffix(q, "*")))
|
||||
min := offset
|
||||
max := min + size - 1
|
||||
resp, err := s.sAlbum.Search(q, min, max)
|
||||
resp, err := s.albumRepo.Search(q, offset, size)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
res := make(Entries, 0, len(resp))
|
||||
for _, id := range resp {
|
||||
al, err := s.albumRepo.Get(id)
|
||||
if criticalError(ctx, "Album", id, err) {
|
||||
for _, al := range resp {
|
||||
if criticalError(ctx, "Album", al.ID, err) {
|
||||
return nil, err
|
||||
}
|
||||
if err == nil {
|
||||
res = append(res, FromAlbum(al))
|
||||
res = append(res, FromAlbum(&al))
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
|
|
@ -129,9 +126,7 @@ func (s *search) SearchAlbum(ctx context.Context, q string, offset int, size int
|
|||
|
||||
func (s *search) SearchSong(ctx context.Context, q string, offset int, size int) (Entries, error) {
|
||||
q = sanitize.Accents(strings.ToLower(strings.TrimSuffix(q, "*")))
|
||||
min := offset
|
||||
max := min + size
|
||||
resp, err := s.mfileRepo.Search(q, min, max)
|
||||
resp, err := s.mfileRepo.Search(q, offset, size)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue