[mb-commits] branch, beta, updated. Merge branch 'collection-sorting' into beta MBS-5723: Allow sorting collectio...

MusicBrainz Git Server <[email protected]> Sun, 06 Jan 2013 02:42:05 +0000
Newsgroups gmane.comp.audio.musicbrainz.cvs
Message-ID <E1TrgBZ-0004Ri-NH@wiley>
The branch, beta has been updated
       via  http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=baf5123b61a740a16b6165eec05a1950cb52613e (commit)
       via  http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=49f2447e0d55bd437d74ecc0dd14a5209bbba70e (commit)
      from  http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=e1adbb42bab3567de003f4cfb43c9b31896c962f (commit)

Summary of changes:
 lib/MusicBrainz/Server/Data/Release.pm |   32 ++++++++++++++++++++++++++++++++
 root/collection/index.tt               |   10 +++++-----
 2 files changed, 37 insertions(+), 5 deletions(-)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit baf5123b61a740a16b6165eec05a1950cb52613e
Merge: e1adbb4 49f2447
Author: Ian McEwen <[email protected]>
Date:   Sat Jan 5 19:40:43 2013 -0700

    Merge branch 'collection-sorting' into beta
    
    * collection-sorting:
      MBS-5723: Allow sorting collections by any column


commit 49f2447e0d55bd437d74ecc0dd14a5209bbba70e
Author: Ian McEwen <[email protected]>
Date:   Mon Dec 31 14:40:37 2012 -0700

    MBS-5723: Allow sorting collections by any column

diff --git a/lib/MusicBrainz/Server/Data/Release.pm b/lib/MusicBrainz/Server/Data/Release.pm
index 3a3ceb0..9238f0a 100644
--- a/lib/MusicBrainz/Server/Data/Release.pm
+++ b/lib/MusicBrainz/Server/Data/Release.pm
@@ -506,11 +506,43 @@ sub find_by_collection
     my $order_by = order_by($order, "date", {
         "date"   => "date_year, date_month, date_day, musicbrainz_collate(name.name)",
         "title"  => "musicbrainz_collate(name.name), date_year, date_month, date_day",
+        "country"  => "country, date_year, date_month, date_day",
         "artist" => sub {
             $extra_join = "JOIN artist_credit ac ON ac.id = release.artist_credit
                            JOIN artist_name ac_name ON ac_name.id=ac.name";
             return "musicbrainz_collate(ac_name.name), date_year, date_month, date_day, musicbrainz_collate(name.name)";
         },
+        "label" => sub {
+            $extra_join = "LEFT OUTER JOIN
+                (SELECT release, array_agg(musicbrainz_collate(label_name.name)) AS labels FROM release_label
+                    JOIN label ON release_label.label = label.id
+                    JOIN label_name ON label.sort_name = label_name.id
+                    GROUP BY release) rl
+                ON rl.release = release.id";
+            return "rl.labels, date_year, date_month, date_day, musicbrainz_collate(name.name)";
+        },
+        "catno" => sub {
+            $extra_join = "LEFT OUTER JOIN
+                (SELECT release, array_agg(catalog_number) AS catnos FROM release_label GROUP BY release) rl
+                ON rl.release = release.id";
+            return "rl.catnos, date_year, date_month, date_day, musicbrainz_collate(name.name)";
+        },
+        "format" => sub {
+            $extra_join = "LEFT OUTER JOIN
+                (SELECT release, array_agg(medium_format.name) AS formats FROM medium
+                    JOIN medium_format ON medium.format = medium_format.id
+                    GROUP BY release) medium
+                ON medium.release = release.id";
+            return "medium.formats, date_year, date_month, date_day, musicbrainz_collate(name.name)";
+        },
+        "tracks" => sub {
+            $extra_join = "JOIN
+                (SELECT medium.release, sum(tracklist.track_count) AS total_track_count
+                    FROM medium JOIN tracklist on medium.tracklist = tracklist.id
+                    GROUP BY medium.release) medium
+                ON medium.release = release.id";
+            return "medium.total_track_count, date_year, date_month, date_day, musicbrainz_collate(name.name)";
+        },
     });
 
     my $query = "SELECT " . $self->_columns . "
diff --git a/root/collection/index.tt b/root/collection/index.tt
index 5874ad1..16e4e1f 100644
--- a/root/collection/index.tt
+++ b/root/collection/index.tt
@@ -9,12 +9,12 @@
                   [% IF my_collection %]<th><input type="checkbox" /></th>[% END %]
                   [% sortble_table_header('title', l('Release')) %]
                   [% sortble_table_header('artist', l('Artist')) %]
-                  <th>[% l('Format') %]</th>
-                  <th>[% l('Tracks') %]</th>
+                  [% sortble_table_header('format', l('Format')) %]
+                  [% sortble_table_header('tracks', l('Tracks')) %]
                   [% sortble_table_header('date', l('Date')) %]
-                  <th>[% l('Country') %]</th>
-                  <th>[% l('Label') %]</th>
-                  <th>[% l('Catalog#') %]</th>
+                  [% sortble_table_header('country', l('Country')) %]
+                  [% sortble_table_header('label', l('Label')) %]
+                  [% sortble_table_header('catno', l('Catalog#')) %]
               </tr>
           </thead>
           <tbody>

-----------------------------------------------------------------------


hooks/post-receive
-- 
mb_server