From 9d4892061b13e45321116e3eb455479da5d72dba Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 23 Jun 2021 12:28:39 -0400 Subject: [PATCH] LP#1895052: Allow pickup lib to control stalling This commit provides a new YAOUS that, when set, takes precedence over the current "soft stalling interval" YAOUS. Instead of limiting capture to items owned by the pickup library (or the directly targeted item) based on the context of scanned item's circulating library, it instead restricts op capture to holds that have a pickup library of the scanning location when the hold is younger that the interval, base on the context of the pickup location of each hold. tl;dr: It allows the pickup library to control op capture stalling rather than the circulating library of an arbitrary scanned item. Signed-off-by: Mike Rylander Signed-off-by: Jason Stephenson Signed-off-by: John Amundson Signed-off-by: Galen Charlton --- .../Application/Storage/Publisher/action.pm | 27 ++++++++++++++++++++-- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 11 ++++++++- .../sql/Pg/upgrade/XXXX.data.stalling-YAOUS.sql | 20 ++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.stalling-YAOUS.sql diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm index 94ea9cd850..b921e6c8da 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm @@ -577,11 +577,34 @@ sub nearest_hold { 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%' ) + LEFT JOIN LATERAL ( + SELECT OILS_JSON_TO_TEXT(value) AS age + FROM actor.org_unit_ancestor_setting('circ.pickup_hold_stalling.soft', h.pickup_lib) + ) AS pickup_stall ON TRUE $addl_join WHERE hm.target_copy = ? - /* not protected, or protection is expired or we're in range */ + + /* not protected, or protection is expired or we're in range */ AND (cahp.id IS NULL OR (AGE(NOW(),acp.active_date) >= cahp.age OR cahp.prox >= hm.proximity)) - AND (AGE(NOW(),h.request_time) >= CAST(? AS INTERVAL) OR hm.proximity = 0 OR p.prox = 0) + + /* the complicated hold stalling logic */ + AND CASE WHEN pickup_stall.age IS NOT NULL AND h.request_time + pickup_stall.age::INTERVAL > NOW() + THEN -- pickup lib oriented stalling is configured for this hold's pickup lib, and it's "too young" + CASE WHEN p.prox = 0 + THEN TRUE -- Cheap test: allow it when scanning at pickup lib + ELSE action.hold_copy_calculated_proximity( -- have to call this because we don't know if pprox will be included + h.id, + acp.id, + p.from_org -- equals scan lib, see first JOIN above + ) <= 0 -- else more expensive test for scan-lib calc prox + END + ELSE ( h.request_time + CAST(? AS INTERVAL) < NOW() + OR hm.proximity <= 0 + OR p.prox = 0 + ) -- not "too young" OR copy-owner/pickup prox OR scan-lib/pickup prox + END + + /* simple, quick tests */ AND h.capture_time IS NULL AND h.cancel_time IS NULL AND (h.expire_time IS NULL OR h.expire_time > NOW()) diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index f3eba61b7f..397cfa3d96 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -3598,7 +3598,16 @@ INSERT into config.org_unit_setting_type 'Soft stalling interval', 'coust', 'label'), oils_i18n_gettext('circ.hold_stalling.soft', - 'How long to wait before allowing remote items to be opportunistically captured for a hold. Example "5 days"', + $$How long to wait before allowing opportunistic capture of holds with a pickup library other than the context item's circulating library$$, -- ' vim + 'coust', 'description'), + 'interval', null) + +,( 'circ.pickup_hold_stalling.soft', 'holds', + oils_i18n_gettext('circ.pickup_hold_stalling.soft', + 'Pickup Library Soft stalling interval', + 'coust', 'label'), + oils_i18n_gettext('circ.pickup_hold_stalling.soft', + 'When set for the pickup library, this specifies that only items scanned at the pickup library can be opportunistically captured for this time period. Example "5 days". This setting takes precedence over "Soft stalling interval" (circ.hold_stalling.soft).', 'coust', 'description'), 'interval', null) diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.stalling-YAOUS.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.stalling-YAOUS.sql new file mode 100644 index 0000000000..4ddcafcb26 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.stalling-YAOUS.sql @@ -0,0 +1,20 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +UPDATE config.org_unit_setting_type + SET description = $$How long to wait before allowing opportunistic capture of holds with a pickup library other than the context item's circulating library$$ -- ' vim + WHERE name = 'circ.hold_stalling.soft'; + +INSERT into config.org_unit_setting_type +( name, grp, label, description, datatype, fm_class ) VALUES +( 'circ.pickup_hold_stalling.soft', + 'holds', + 'Pickup Library Soft stalling interval', + 'When set for the pickup library, this specifies that only items scanned at the pickup library can be opportunistically captured for this time period. Example "5 days". This setting takes precedence over "Soft stalling interval" (circ.hold_stalling.soft).', + 'interval', + null +); + +COMMIT; + -- 2.11.0