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

Sort albums using sort_name column first #434

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

alessandrococco
Copy link

@alessandrococco alessandrococco commented Mar 13, 2024

WORK IN (VERY SLOW) PROGRESS


This PR improves how the albums are sorted in the Albums / All view: if a sort_name exists then it will be used first. E.g. the ALBUM A Fallen Temple will appear under the letter F (because the ALBUMSORT is Fallen Temple, A).

Before:

image

After:

image

@@ -167,10 +167,10 @@ namespace lms::db
case ReleaseSortMethod::None:
break;
case ReleaseSortMethod::Name:
query.orderBy("r.name COLLATE NOCASE");
query.orderBy("COALESCE(r.sort_name, r.name) COLLATE NOCASE");
Copy link
Owner

@epoupon epoupon Mar 14, 2024

Choose a reason for hiding this comment

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

I have a lot of albums without sort_name and it does not seem to work well.
Unfortunately, sort_name is always stored as non null, so "" is always taken into account for sort_name.
So first option would be to store sort_name using std::optional<std::string> (and handle migration)
Second option would be to change the query to something like CASE WHEN sort_name <> '' THEN sort_name COLLATE NOCASE ELSE name COLLATE NOCASE END

Copy link
Author

Choose a reason for hiding this comment

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

Aaargh, I didn't notice the "" thing because all my albums have the ALBUMSORT tag 😅

I'll try the way of the optional ™️ in the next days.

Copy link
Owner

Choose a reason for hiding this comment

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

No problem, thanks again for the PR :)
The std::optional way is indeed the best choice. Don't hesitate to tell me if you need help! x

@alessandrococco alessandrococco marked this pull request as draft March 16, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants