feat: filter artist albums by type, default to album|ep|single
This commit is contained in:
@@ -114,9 +114,10 @@ func (s *MetadataServer) SearchAlbums(ctx context.Context, req *metadatav1.Searc
|
||||
limit = 25
|
||||
}
|
||||
|
||||
log.Debug().Str("query", req.Query).Str("artist", req.Artist).Int("limit", limit).Int("offset", int(req.Offset)).Msg("searching albums")
|
||||
albumTypes := defaultAlbumTypes(req.AlbumTypes)
|
||||
log.Debug().Str("query", req.Query).Str("artist", req.Artist).Int("limit", limit).Int("offset", int(req.Offset)).Strs("album_types", albumTypes).Msg("searching albums")
|
||||
|
||||
result, err := svc.SearchAlbums(ctx, req.Query, req.Artist, limit, int(req.Offset))
|
||||
result, err := svc.SearchAlbums(ctx, req.Query, req.Artist, limit, int(req.Offset), albumTypes)
|
||||
if err != nil {
|
||||
return nil, toGRPCError(ctx, err)
|
||||
}
|
||||
@@ -176,9 +177,10 @@ func (s *MetadataServer) GetArtistAlbums(ctx context.Context, req *metadatav1.Ge
|
||||
limit = 25
|
||||
}
|
||||
|
||||
log.Debug().Str("artist_id", req.ArtistId).Int("limit", limit).Int("offset", int(req.Offset)).Msg("getting artist albums")
|
||||
albumTypes := defaultAlbumTypes(req.AlbumTypes)
|
||||
log.Debug().Str("artist_id", req.ArtistId).Int("limit", limit).Int("offset", int(req.Offset)).Strs("album_types", albumTypes).Msg("getting artist albums")
|
||||
|
||||
result, err := svc.GetArtistAlbums(ctx, req.ArtistId, limit, int(req.Offset))
|
||||
result, err := svc.GetArtistAlbums(ctx, req.ArtistId, limit, int(req.Offset), albumTypes)
|
||||
if err != nil {
|
||||
return nil, toGRPCError(ctx, err)
|
||||
}
|
||||
@@ -268,6 +270,15 @@ func (s *MetadataServer) SyncArtist(ctx context.Context, req *metadatav1.SyncArt
|
||||
return nil, status.Error(codes.Unimplemented, "sync not yet implemented")
|
||||
}
|
||||
|
||||
var defaultTypes = []string{"album", "ep", "single"}
|
||||
|
||||
func defaultAlbumTypes(types []string) []string {
|
||||
if len(types) > 0 {
|
||||
return types
|
||||
}
|
||||
return defaultTypes
|
||||
}
|
||||
|
||||
func toGRPCError(ctx context.Context, err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user