fix(subsonic): artist search in search3 endpoint
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -68,17 +68,25 @@ func (api *Router) searchAll(ctx context.Context, sp *searchParams, musicFolderI
|
|||||||
|
|
||||||
// Create query options for library filtering
|
// Create query options for library filtering
|
||||||
var options []model.QueryOptions
|
var options []model.QueryOptions
|
||||||
|
var artistOptions []model.QueryOptions
|
||||||
if len(musicFolderIds) > 0 {
|
if len(musicFolderIds) > 0 {
|
||||||
|
// For MediaFiles and Albums, use direct library_id filter
|
||||||
options = append(options, model.QueryOptions{
|
options = append(options, model.QueryOptions{
|
||||||
Filters: Eq{"library_id": musicFolderIds},
|
Filters: Eq{"library_id": musicFolderIds},
|
||||||
})
|
})
|
||||||
|
// For Artists, use the repository's built-in library filtering mechanism
|
||||||
|
// which properly handles the library_artist table joins
|
||||||
|
// TODO Revisit library filtering in sql_base_repository.go
|
||||||
|
artistOptions = append(artistOptions, model.QueryOptions{
|
||||||
|
Filters: Eq{"library_artist.library_id": musicFolderIds},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run searches in parallel
|
// Run searches in parallel
|
||||||
g, ctx := errgroup.WithContext(ctx)
|
g, ctx := errgroup.WithContext(ctx)
|
||||||
g.Go(callSearch(ctx, api.ds.MediaFile(ctx).Search, q, sp.songOffset, sp.songCount, &mediaFiles, options...))
|
g.Go(callSearch(ctx, api.ds.MediaFile(ctx).Search, q, sp.songOffset, sp.songCount, &mediaFiles, options...))
|
||||||
g.Go(callSearch(ctx, api.ds.Album(ctx).Search, q, sp.albumOffset, sp.albumCount, &albums, options...))
|
g.Go(callSearch(ctx, api.ds.Album(ctx).Search, q, sp.albumOffset, sp.albumCount, &albums, options...))
|
||||||
g.Go(callSearch(ctx, api.ds.Artist(ctx).Search, q, sp.artistOffset, sp.artistCount, &artists, options...))
|
g.Go(callSearch(ctx, api.ds.Artist(ctx).Search, q, sp.artistOffset, sp.artistCount, &artists, artistOptions...))
|
||||||
err := g.Wait()
|
err := g.Wait()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Debug(ctx, fmt.Sprintf("Search resulted in %d songs, %d albums and %d artists",
|
log.Debug(ctx, fmt.Sprintf("Search resulted in %d songs, %d albums and %d artists",
|
||||||
|
|||||||
Reference in New Issue
Block a user