Avoid checkin capture for CAPTURE-blocked holds
authorMike Rylander <mrylander@gmail.com>
Tue, 10 Apr 2012 14:21:02 +0000 (10:21 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 24 Jul 2012 15:49:31 +0000 (11:49 -0400)
Teach the nearest_hold sub about CAPTURE-blocking penalties

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

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

index ada8dc4..78b0596 100644 (file)
@@ -294,8 +294,8 @@ sub nearest_hold {
        local $OpenILS::Application::Storage::WRITE = 1;
 
        my $holdsort = isTrue($fifo) ?
-            "pgt.hold_priority, CASE WHEN h.cut_in_line IS TRUE THEN 0 ELSE 1 END, h.request_time, h.selection_depth DESC, p.prox " :
-            "p.prox, pgt.hold_priority, CASE WHEN h.cut_in_line IS TRUE THEN 0 ELSE 1 END, h.selection_depth DESC, h.request_time ";
+                       "pgt.hold_priority, CASE WHEN h.cut_in_line IS TRUE THEN 0 ELSE 1 END, h.request_time, h.selection_depth DESC, p.prox " :
+                       "p.prox, pgt.hold_priority, CASE WHEN h.cut_in_line IS TRUE THEN 0 ELSE 1 END, h.selection_depth DESC, h.request_time ";
 
        my $ids = action::hold_request->db_Main->selectcol_arrayref(<<" SQL", {}, $here, $cp, $age);
                SELECT  h.id
@@ -304,12 +304,17 @@ sub nearest_hold {
                        JOIN action.hold_copy_map hm ON (hm.hold = h.id)
                        JOIN actor.usr au ON (au.id = h.usr)
                        JOIN permission.grp_tree pgt ON (au.profile = pgt.id)
+                       LEFT JOIN actor.usr_standing_penalty ausp
+                               ON ( au.id = ausp.usr AND ( ausp.stop_date IS NULL OR ausp.stop_date > NOW() ) )
+                       LEFT JOIN config.standing_penalty csp
+                               ON ( csp.id = ausp.standing_penalty AND csp.block_list LIKE '%CAPTURE%' )
                  WHERE hm.target_copy = ?
                        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
                        AND (h.expire_time IS NULL OR h.expire_time > NOW())
-            AND h.frozen IS FALSE
+                       AND h.frozen IS FALSE
+                       AND csp.id IS NULL
                ORDER BY CASE WHEN h.hold_type IN ('R','F') THEN 0 ELSE 1 END, $holdsort
                LIMIT $limit
        SQL