backporting think-o fix for hold stalling
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 25 Oct 2007 16:10:54 +0000 (16:10 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 25 Oct 2007 16:10:54 +0000 (16:10 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@7930 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 06f2b15..cd69b4b 100644 (file)
@@ -204,20 +204,18 @@ __PACKAGE__->register_method(
 sub nearest_hold {
        my $self = shift;
        my $client = shift;
-       my $pl = shift;
+       my $here = shift;
        my $cp = shift;
        my $limit = int(shift()) || 10;
-       my $age = shift() || '0';
-       my $prox = shift() || 0;
+       my $age = shift() || '0 seconds';
 
-       my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $cp, $pl, $age, $prox);
+       my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $here, $cp, $age);
                SELECT  h.id
                  FROM  action.hold_request h
+                       JOIN actor.org_unit_proximity p ON (p.from_org = ? AND p.to_org = h.pickup_lib)
                        JOIN action.hold_copy_map hm ON (hm.hold = h.id)
-                       JOIN actor.org_unit_proximity p ON (p.from_org = h.pickup_lib)
                  WHERE hm.target_copy = ?
-                       AND p.to_org = ?
-                       AND (h.request_time + ? < NOW() OR p.prox <= ?)
+                       AND (AGE(NOW(),h.request_time) >= CAST(? AS INTERVAL) OR p.prox = 0)
                        AND h.capture_time IS NULL
                        AND h.cancel_time IS NULL
                ORDER BY