add support for sorting the pull list by asset.copy_location_order when set
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Oct 2009 17:41:55 +0000 (17:41 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Oct 2009 17:41:55 +0000 (17:41 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14652 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm

index cd57a8d..7a4dfbe 100644 (file)
@@ -13,6 +13,14 @@ __PACKAGE__->columns( Primary => qw/id/ );
 __PACKAGE__->columns( Essential => qw/name owning_lib holdable hold_verify opac_visible circulate/ );
 
 #-------------------------------------------------------------------------------
+package asset::copy_location_order;
+use base qw/asset/;
+
+__PACKAGE__->table( 'asset_copy_location_order' );
+__PACKAGE__->columns( Primary => qw/id/ );
+__PACKAGE__->columns( Essential => qw/location org position/ );
+
+#-------------------------------------------------------------------------------
 package asset::call_number;
 use base qw/asset/;
 
index 3bb16d9..2da5d7c 100644 (file)
        asset::call_number->sequence( 'asset.call_number_id_seq' );
        
        #---------------------------------------------------------------------
+       package asset::copy_location_order;
+       
+       asset::copy_location_order->table( 'asset.copy_location_order' );
+       asset::copy_location_order->sequence( 'asset.copy_location_order_id_seq' );
+
+       #---------------------------------------------------------------------
        package asset::copy_location;
        
        asset::copy_location->table( 'asset.copy_location' );
index 7b431d4..5f405cb 100644 (file)
@@ -408,6 +408,7 @@ sub hold_pull_list {
        return undef unless ($ou);
        my $h_table = action::hold_request->table;
        my $a_table = asset::copy->table;
+       my $ord_table = asset::copy_location_order->table;
 
        my $idlist = 1 if ($self->api_name =~/id_list/o);
 
@@ -418,12 +419,13 @@ sub hold_pull_list {
                SELECT  h.*
                  FROM  $h_table h
                        JOIN $a_table a ON (h.current_copy = a.id)
+                       LEFT JOIN $ord_table ord (a.location = ord.location AND a.circ_lib = ord.org)
                  WHERE a.circ_lib = ?
                        AND h.capture_time IS NULL
                        AND h.cancel_time IS NULL
                        AND (h.expire_time IS NULL OR h.expire_time > NOW())
                        $status_filter
-                 ORDER BY h.request_time ASC
+                 ORDER BY CASE WHEN ord.position IS NOT NULL THEN ord.position ELSE 999 END, h.request_time
                  LIMIT $limit
                  OFFSET $offset
        SQL