added sort order on SELECTs so that selection_depth is used to fill "closer" holds...
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 11 Feb 2006 15:49:03 +0000 (15:49 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 11 Feb 2006 15:49:03 +0000 (15:49 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3030 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm

index 4ae2f1c..f2bf6e9 100644 (file)
@@ -63,7 +63,7 @@ sub nearest_hold {
                  WHERE h.pickup_lib = ?
                        AND hm.target_copy = ?
                        AND h.capture_time IS NULL
-               ORDER BY h.pickup_lib - (SELECT home_ou FROM actor.usr a WHERE a.id = h.usr), h.request_time
+               ORDER BY h.selection_depth DESC, h.pickup_lib - (SELECT home_ou FROM actor.usr a WHERE a.id = h.usr), h.request_time
                LIMIT 1
        SQL
        return $id;
@@ -414,12 +414,12 @@ sub new_hold_copy_targeter {
                                                          fulfillment_time => undef,
                                                          prev_check_time => { '<=' => $expire_threshold },
                                                        },
-                                                       { order_by => 'request_time,prev_check_time' } ) ];
+                                                       { order_by => 'selection_depth DESC, request_time,prev_check_time' } ) ];
                        push @$holds, action::hold_request->search(
                                                        capture_time => undef,
                                                        fulfillment_time => undef,
                                                        prev_check_time => undef,
-                                                       { order_by => 'request_time' } );
+                                                       { order_by => 'selection_depth DESC, request_time' } );
                }
        } catch Error with {
                my $e = shift;