Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More releases rework #1303

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Slim/Control/Queries.pm
Original file line number Diff line number Diff line change
Expand Up @@ -929,9 +929,16 @@ sub albumsQuery {
}

if ( $tags =~ /R/ ) {
$contributorRoleSth ||= $dbh->prepare_cached("SELECT role FROM contributor_album WHERE album = ? AND contributor = ?");
my $rolesRef = $dbh->selectall_arrayref($contributorRoleSth, , undef, $c->{'albums.id'}, $contributorID || $c->{'albums.contributor'});

my $rolesRef;
my $contributorRoleSql = "SELECT role FROM contributor_album WHERE album = ?";
if ( $contributorID ) {
$contributorRoleSql .= " AND contributor = ?" if $contributorID;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for $contributorID is redundant here.

$contributorRoleSth ||= $dbh->prepare_cached($contributorRoleSql);
$rolesRef = $dbh->selectall_arrayref($contributorRoleSth, , undef, $c->{'albums.id'}, $contributorID);
} else {
$contributorRoleSth ||= $dbh->prepare_cached($contributorRoleSql);
$rolesRef = $dbh->selectall_arrayref($contributorRoleSth, , undef, $c->{'albums.id'});
}
if ($rolesRef) {
my $roles = join(',', map { $_->[0] } @$rolesRef);
$request->addResultLoopIfValueDefined($loopname, $chunkCount, 'role_ids', $roles);
Expand Down
19 changes: 11 additions & 8 deletions Slim/Menu/BrowseLibrary/Releases.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ my $prefs = preferences('server');
sub _releases {
my ($client, $callback, $args, $pt) = @_;
my @searchTags = $pt->{'searchTags'} ? @{$pt->{'searchTags'}} : ();
my @originalSearchTags = @searchTags;
my $tags = 'lWRSw';
my $library_id = $args->{'library_id'} || $pt->{'library_id'};
my $orderBy = $args->{'orderBy'} || $pt->{'orderBy'};
my $menuMode = $args->{'params'}->{'menu_mode'};
my $menuRoles = $args->{'params'}->{'menu_roles'};
my $search = $args->{'search'};

push @searchTags, "search:$search" if $search && !grep /search:/, @searchTags;
my @originalSearchTags = @searchTags;

# map menuRoles to name for readability
$menuRoles = join(',', map { Slim::Schema::Contributor->roleToType($_) } split(',', $menuRoles || ''));
Expand Down Expand Up @@ -52,7 +55,7 @@ sub _releases {
main::INFOLOG && $log->is_info && $log->info("$query ($index, $quantity): tags ->", join(', ', @searchTags));

# get the artist's albums list to create releases sub-items etc.
my $request = Slim::Control::Request->new( undef, [ $query, 0, MAX_ALBUMS, @searchTags, 'role_id:'. ($menuRoles ? $menuRoles : join(',',Slim::Schema::Contributor->contributorRoles)) ] );
my $request = Slim::Control::Request->new( undef, [ $query, 0, MAX_ALBUMS, @searchTags ] );
$request->execute();

$log->error($request->getStatusText()) if $request->isStatusError();
Expand Down Expand Up @@ -167,14 +170,14 @@ sub _releases {

if ($releaseTypes{uc($releaseType)}) {
$pt->{'searchTags'} = $releaseType eq 'COMPILATION'
? [@searchTags, 'compilation:1', "album_id:" . join(',', @{$albumList{$releaseType}})]
: [@searchTags, "compilation:0", "release_type:$releaseType", "album_id:" . join(',', @{$albumList{$releaseType}})];
? [@searchTags, 'compilation:1']
: [@searchTags, "compilation:0", "release_type:$releaseType"];
push @items, _createItem($name, [{%$pt}]);
}
}

if (my $albumIds = delete $contributions{COMPOSERALBUM}) {
$pt->{'searchTags'} = [@searchTags, "role_id:COMPOSER", "album_id:" . join(',', @$albumIds)];
$pt->{'searchTags'} = [@searchTags, "role_id:COMPOSER"];
push @items, _createItem(cstring($client, 'COMPOSERALBUMS'), [{%$pt}]);
}

Expand All @@ -186,18 +189,18 @@ sub _releases {
playlist => \&_tracks,
# for compositions we want to have the compositions only, not the albums
url => \&_tracks,
passthrough => [ { searchTags => [@searchTags, "role_id:COMPOSER", "album_id:" . join(',', @$albumIds)] } ],
passthrough => [ { searchTags => [@searchTags, "role_id:COMPOSER"] } ],
};
}

if (my $albumIds = delete $contributions{TRACKARTIST}) {
$pt->{'searchTags'} = [@searchTags, "role_id:TRACKARTIST", "album_id:" . join(',', @$albumIds)];
$pt->{'searchTags'} = [@searchTags, "role_id:TRACKARTIST"];
push @items, _createItem(cstring($client, 'APPEARANCES'), [{%$pt}]);
}

foreach my $role (sort keys %contributions) {
my $name = cstring($client, $role) if Slim::Utils::Strings::stringExists($role);
$pt->{'searchTags'} = [@searchTags, "role_id:$role", "album_id:" . join(',', @{$contributions{$role}})];
$pt->{'searchTags'} = [@searchTags, "role_id:$role"];
push @items, _createItem($name || ucfirst($role), [{%$pt}]);
}

Expand Down