Implement Album search with SQL
This commit is contained in:
+5
-10
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user