-
Notifications
You must be signed in to change notification settings - Fork 309
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
More releases rework #1303
Conversation
Signed-off-by: darrell-k <darrell@darrell.org.uk>
...and the DCO worked :) |
Slim/Control/Queries.pm
Outdated
if ( $contributorID ) { | ||
$contributorRoleSql .= " AND contributor = ?" if $contributorID; |
There was a problem hiding this comment.
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.
Signed-off-by: darrell-k <darrell@darrell.org.uk>
While we're here, maybe we should increase this (Material Skin would use 25000)?
|
Has it ever caused a problem? Do you remember why we set this relatively low? In the case of But just skimming that page a few things sprang to my mind: You're redefining multiple variables of the same name On the same line: we don't need a The outer, greater loop doesn't name |
With these changes it would only cause a problem if not all release types/contributor roles were identified by looking at the first 1500 albums. But I don't think that increasing it substantially would cause problems, it's not like we're pumping the results out over the network to clients. (Material gets away with its much larger limit, even though that is going out to the client.) I'll work on the other points you make. |
@michaelherger Further testing of this has brought to light a situation where the Consider 2 albums where on one, an artist is both ARTIST and COMPOSER, and another where they are only COMPOSER (eg Bob Dylan is often tagged like this, because of the number of covers by other artists). For the album where Bob is both ARTIST and COMPOSER, the main loop will add the album id only to All is well with the current code when creating the menu entries with So either:
I think 1 is not good enough, and that 2 would increase the complexity of _releases again, so I think I'd go for 3. But what do you think? And, coincidently, a user has asked on the forums if they could also see compilations in their user-defined release type categories (that is, not one of |
Thanks for the update. For 9.0 I'd actually opt for 1.) - with an additional cap added to the array. Just trim it if it's too long. It's unlikely to happen, as you say. And would require the fewest changes, wouldn't it? For 9.1 you could still try to do the real fix. Just make sure you document the decision and the array in a comment so next time we better understand the decision. |
Signed-off-by: darrell-k <darrell@darrell.org.uk>
Latest version pushed: not fully tested yet, but making it available for comments. |
Slim/Control/Queries.pm
Outdated
my $rolesRef; | ||
my $contributorRoleSql = "SELECT role FROM contributor_album WHERE album = ?"; | ||
if ( $contributorID ) { | ||
$contributorRoleSql .= " AND contributor = ?"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only this line is conditional, isn't it? Keep the rest outside, as it's identical. That would be less code to maintain.
Slim/Menu/BrowseLibrary/Releases.pm
Outdated
my $limitList = sub { | ||
my $list = shift; | ||
my $name = shift; | ||
my $albumCount = scalar @$list; | ||
if ( $albumCount > LIST_LIMIT ) { | ||
splice @$list, LIST_LIMIT; | ||
$name .= ' (' . cstring($client, 'FIRST') . ' ' . LIST_LIMIT . ' ' . cstring($client, 'ALBUMS') .')'; | ||
} | ||
return $list, $name; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually prefer not to create closures unless it really simplifies things by re-using a lot of the variables. The only one missing here would be $client
. Would you mind changing this to a regular sub?
Adding new strings sucks. But concatenating strings often doesn't work with language other than "yours". Of the three languages I know one would fail (French). I know this will hardly ever be used, but could you still create a new string? Thanks!
Slim/Menu/BrowseLibrary/Releases.pm
Outdated
splice @$list, LIST_LIMIT; | ||
$name .= ' (' . cstring($client, 'FIRST') . ' ' . LIST_LIMIT . ' ' . cstring($client, 'ALBUMS') .')'; | ||
} | ||
return $list, $name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As $list
is a list reference, you actually don't have to return it. It's modified directly. Therefore ($listRef, $name) = $limitList($listRef, $name);
is overwriting $listRef
with itself, like $a = $a
. You don't have to return $list
.
Unless I'm completely wrong, of course.
Signed-off-by: darrell-k <darrell@darrell.org.uk>
Changes pushed. Seems to work well. I used deepl.com for translations. |
Slim/Control/Queries.pm
Outdated
my $contributorRoleSql = "SELECT role FROM contributor_album WHERE album = ?"; | ||
$contributorRoleSql .= " AND contributor = ?" if $contributorID; | ||
$contributorRoleSth ||= $dbh->prepare_cached($contributorRoleSql); | ||
if ( $contributorID ) { | ||
$contributorRoleSql .= " AND contributor = ?"; | ||
$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'}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really sorry about the previous comment on this and my request to change it... the $rolesRef
line was wrapped on my screen and I thought it was identical in both lines... I thought only one line was conditional, when the SQL statement, and calling it, are, of course. Considering this, I'd prefer the previous version. I'm really sorry!
But while we're at it: is there one comma too many in selectall_arrayref($contributorRoleSth, , undef, $c->{'albums.id'})
? Before the undef
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered about that. According to the definition:
$ary_ref = $dbh->selectall_arrayref($statement, \%attr, @bind_values);
I suppose what must be happening with the existing code is that Perl is constructing @bind_values
from undef, $c->{'albums.id'} and $contributorID
and then ignoring the undef element when deciding if we have the right number of bind variables.
I've changed the statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, with a bit more playing about, it's not doing that, it seems to just ignore the repeated comma. Anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And with all this parameter confusion you didn't see my being sorry? 😁 Never mind: I'm going to merge and revert what I made you do myself. I'm still sorry about that confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saw it, but thought it didn't matter one way or the other. One less line of code but an extra if ...
If you're using Visual Studio Code you can enable Copilot, which has been super helpful with this kind of work: after writing the EN version, it would often be enough to type the new language code, and Copilot would automatically complete the full line. |
Signed-off-by: darrell-k <darrell@darrell.org.uk>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Looking into https://forums.lyrion.org/forum/user-forums/logitech-media-server/1746593-9-0-2-albums-search-query-fails I found that at some point in the many versions of
Releases.pm
thealbum_id
array (introduced by me!) became redundant.At least, I can't find any differences in the results from
albumsQuery
.This also fixes the bug where the search parameter was being ignored. And another one I found when testing: the
/R/
tag wasn't working properly when noartist_id
was passed, it was using onlyalbums.contributor
to find the required roles, which meant that other roles for the album were not being passed back.I also simplified the main
$request
which drives_releases
:$menuRoles
is already added to@searchTags
and the alternative of adding all roles to the request is unnecessary (and might be causing an explosion in the number of contributors added toartists
andartist_ids
returned byalbumsQuery
).Once this gets past pre-merge testing, we should ask users of 9.0.2 to give release types in Default Skin a good going over.