Merge lp:~vthompson/mediascanner2/add-case-insensitive-sorting into lp:mediascanner2

Proposed by Victor Thompson
Status: Needs review
Proposed branch: lp:~vthompson/mediascanner2/add-case-insensitive-sorting
Merge into: lp:mediascanner2
Diff against target: 70 lines (+8/-3)
1 file modified
src/mediascanner/MediaStore.cc (+8/-3)
To merge this branch: bzr merge lp:~vthompson/mediascanner2/add-case-insensitive-sorting
Reviewer Review Type Date Requested Status
James Henstridge Needs Fixing
unity-api-1-bot continuous-integration Approve
Review via email: mp+241230@code.launchpad.net

Commit message

Add case insensitive sorting.

Description of the change

This adds case insensitive sorting.

However, from the Music app side of things there is still another issue. Currently we use the SDK's SortFilterModel to sort the SongsModel on the Songs tab and the AlbumsModel on the Albums tab since both of these models are sorted by artist by default. Unfortunately, the SortFilterModel also has the same A-Za-z sorting issue, so we'd like to be able to drop it and instead have the model sorted by song title in the Songs tab (SongsModel) and by album name in the Albums tab (AlbumsModel). Do we need to file a bug for this, or do we just need assistance in getting the model properly sorted?

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:
https://jenkins.canonical.com/unity-api-1/job/lp-mediascanner2-ci/18/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1716
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1723
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1498
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1498/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1498
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1498/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1498
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1498/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1498
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1498/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1498
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1498/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1498
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1498/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-mediascanner2-ci/18/rebuild

review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) wrote :

I'm not sure what the test coverage is like for this code, but would like to see some regression tests for this as well if possible.

Revision history for this message
James Henstridge (jamesh) wrote :

I remember discussing this with Victor at the time on IRC, and I think the main issues were:

(a) SQLite's "nocase" collation only helped with characters in the 7-bit ASCII range.

(b) The change means we're no longer taking advantage of the indexes to sort results.

And just looking at the diff now, I can see a third problem:

(c) the "COLLATE $collation" modifier binds to the individual terms of the ORDER BY clause rather than being an independent clause itself. This means that for the places where we sort by multiple columns, we're only doing a nocase collation on the last term.

For the sorting issue, it is possible to create indexes like "CREATE INDEX idx_name ON table (column COLLATE nocase)" which can be used for a nocase sorted result set. But I can't seem to avoid the sort when combined with an indexed WHERE filter.

review: Needs Fixing

Unmerged revisions

289. By Victor Thompson

* Add case insensitive sorting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/mediascanner/MediaStore.cc'
--- src/mediascanner/MediaStore.cc 2014-09-24 09:39:06 +0000
+++ src/mediascanner/MediaStore.cc 2014-11-10 02:41:25 +0000
@@ -555,7 +555,7 @@
555 }555 }
556 break;556 break;
557 case MediaOrder::Title:557 case MediaOrder::Title:
558 qs += " ORDER BY title";558 qs += " ORDER BY title COLLATE NOCASE";
559 if (filter.getReverse()) {559 if (filter.getReverse()) {
560 qs += " DESC";560 qs += " DESC";
561 }561 }
@@ -610,7 +610,7 @@
610 switch (filter.getOrder()) {610 switch (filter.getOrder()) {
611 case MediaOrder::Default:611 case MediaOrder::Default:
612 case MediaOrder::Title:612 case MediaOrder::Title:
613 qs += " ORDER BY album";613 qs += " ORDER BY album COLLATE NOCASE";
614 if (filter.getReverse()) {614 if (filter.getReverse()) {
615 qs += " DESC";615 qs += " DESC";
616 }616 }
@@ -645,7 +645,7 @@
645 switch (filter.getOrder()) {645 switch (filter.getOrder()) {
646 case MediaOrder::Default:646 case MediaOrder::Default:
647 case MediaOrder::Title:647 case MediaOrder::Title:
648 qs += " ORDER BY artist";648 qs += " ORDER BY artist COLLATE NOCASE";
649 if (filter.getReverse()) {649 if (filter.getReverse()) {
650 qs += " DESC";650 qs += " DESC";
651 }651 }
@@ -716,6 +716,7 @@
716 }716 }
717 qs += R"(717 qs += R"(
718ORDER BY album_artist, album, disc_number, track_number, title718ORDER BY album_artist, album, disc_number, track_number, title
719COLLATE NOCASE
719LIMIT ? OFFSET ?720LIMIT ? OFFSET ?
720)";721)";
721 Statement query(db, qs.c_str());722 Statement query(db, qs.c_str());
@@ -756,6 +757,7 @@
756 qs += R"(757 qs += R"(
757GROUP BY album, album_artist758GROUP BY album, album_artist
758ORDER BY album_artist, album759ORDER BY album_artist, album
760COLLATE NOCASE
759LIMIT ? OFFSET ?761LIMIT ? OFFSET ?
760)";762)";
761 Statement query(db, qs.c_str());763 Statement query(db, qs.c_str());
@@ -787,6 +789,7 @@
787 qs += R"(789 qs += R"(
788 GROUP BY artist790 GROUP BY artist
789 ORDER BY artist791 ORDER BY artist
792 COLLATE NOCASE
790 LIMIT ? OFFSET ?793 LIMIT ? OFFSET ?
791)";794)";
792 Statement query(db, qs.c_str());795 Statement query(db, qs.c_str());
@@ -816,6 +819,7 @@
816 qs += R"(819 qs += R"(
817 GROUP BY album_artist820 GROUP BY album_artist
818 ORDER BY album_artist821 ORDER BY album_artist
822 COLLATE NOCASE
819 LIMIT ? OFFSET ?823 LIMIT ? OFFSET ?
820)";824)";
821 Statement query(db, qs.c_str());825 Statement query(db, qs.c_str());
@@ -840,6 +844,7 @@
840 WHERE type = ?844 WHERE type = ?
841 GROUP BY genre845 GROUP BY genre
842 ORDER BY genre846 ORDER BY genre
847 COLLATE NOCASE
843 LIMIT ? OFFSET ?848 LIMIT ? OFFSET ?
844)");849)");
845 query.bind(1, (int)AudioMedia);850 query.bind(1, (int)AudioMedia);

Subscribers

People subscribed via source and target branches