backporting hold stalling support to 1.2
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 21 Aug 2007 23:56:29 +0000 (23:56 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 21 Aug 2007 23:56:29 +0000 (23:56 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@7711 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index fb2afeb..39f0b4e 100644 (file)
@@ -183,14 +183,21 @@ sub nearest_hold {
        my $pl = shift;
        my $cp = shift;
        my $limit = int(shift()) || 10;
+       my $age = shift() || '0';
+       my $prox = shift() || 0;
 
-       my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $cp, $pl);
+       my $age_where = '';
+       if ($age) {
+               $age_where = "
+
+       my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $cp, $pl, $age, $prox);
                SELECT  h.id
                  FROM  action.hold_request h
                        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 h.capture_time IS NULL
                        AND h.cancel_time IS NULL
                ORDER BY