LP#1869794 new best hold sort order
authorJason Etheridge <jason@EquinoxInitiative.org>
Wed, 26 Feb 2020 14:40:04 +0000 (09:40 -0500)
committerBen Shum <ben@evergreener.net>
Thu, 30 Apr 2020 18:12:20 +0000 (14:12 -0400)
owning lib to requestee home lib proximity

implementation, release notes and TechRef tweak

Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Signed-off-by: Lindsay Stratton <lstratton@wlsmail.org>
Signed-off-by: Ben Shum <ben@evergreener.net>

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.hpprox-best-hold-sort-order [new file with mode: 0755]
Open-ILS/web/js/dojo/openils/conify/BestHoldOrder.js
docs/RELEASE_NOTES_NEXT/Circulation/hold-sort-order-chase-home-lib-patrons.adoc [new file with mode: 0644]
docs/TechRef/Circ/custom-best-hold-selection.adoc

index e849f66..9225c86 100644 (file)
@@ -2973,6 +2973,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field reporter:label="Name" name="name" reporter:datatype="text"/>
                        <field reporter:label="Capture Lib to Pickup Lib Proximity" name="pprox" reporter:datatype="int" />
                        <field reporter:label="Circ Lib to Request Lib Proximity" name="hprox" reporter:datatype="int" />
+                       <field reporter:label="Owning Lib to Patron Home Lib Proximity" name="owning_lib_to_home_lib_prox" reporter:datatype="int" />
                        <field reporter:label="Adjusted Circ Lib to Pickup Lib Proximity" name="aprox" reporter:datatype="int" />
                        <field reporter:label="Adjusted Capture Location to Pickup Lib Proximity" name="approx" reporter:datatype="int" />
                        <field reporter:label="Hold Priority" name="priority" reporter:datatype="int" />
index 6c69acb..4662c23 100644 (file)
@@ -23,6 +23,7 @@ my $U = "OpenILS::Application::AppUtils";
 my %HOLD_SORT_ORDER_BY = (
     pprox => 'p.prox',
     hprox => 'actor.org_unit_proximity(%d, h.pickup_lib)',  # $cp->call_number->owning_lib
+    owning_lib_to_home_lib_prox => 'actor.org_unit_proximity(%d, au.home_ou)',  # $cp->call_number->owning_lib
     aprox => 'COALESCE(hm.proximity, p.prox)',
     approx => 'action.hold_copy_calculated_proximity(h.id, %d, %d)', # $cp,$here
     priority => 'pgt.hold_priority',
@@ -348,8 +349,9 @@ sub get_hold_sort_order {
     my $row = $dbh->selectrow_hashref(
         q!
         SELECT
-            cbho.pprox, cbho.hprox, cbho.aprox, cbho.approx, cbho.priority,
-            cbho.cut, cbho.depth, cbho.htime, cbho.shtime, cbho.rtime
+            cbho.pprox, cbho.hprox, cbho.owning_lib_to_home_lib_prox, cbho.aprox,
+            cbho.approx, cbho.priority, cbho.cut, cbho.depth, cbho.htime,
+            cbho.shtime, cbho.rtime
         FROM config.best_hold_order cbho
         WHERE id = (
             SELECT oils_json_to_text(value)::INT
@@ -378,6 +380,7 @@ sub build_hold_sort_clause {
 
     my %order_by_sprintf_args = (
         hprox => [$cp->call_number->owning_lib],
+        owning_lib_to_home_lib_prox => [$cp->call_number->owning_lib],
         approx => [$cp->id, $here],
         htime => [$cp->call_number->owning_lib, $cp->call_number->owning_lib],
         shtime => [$cp->call_number->owning_lib, $cp->call_number->owning_lib]
index 64fd79f..ac2df51 100644 (file)
@@ -1140,6 +1140,7 @@ CREATE TABLE config.best_hold_order(
     name        TEXT        UNIQUE,   -- i18n
     pprox       INT, -- copy capture <-> pickup lib prox
     hprox       INT, -- copy circ lib <-> request lib prox
+    owning_lib_to_home_lib_prox      INT, -- copy owning lib <-> user home lib prox
     aprox       INT, -- copy circ lib <-> pickup lib ADJUSTED prox on ahcm
     approx      INT, -- copy capture <-> pickup lib ADJUSTED prox from function
     priority    INT, -- group hold priority
@@ -1154,6 +1155,7 @@ CREATE TABLE config.best_hold_order(
 ALTER TABLE config.best_hold_order ADD CHECK ((
     pprox IS NOT NULL OR
     hprox IS NOT NULL OR
+    owning_lib_to_home_lib_prox IS NOT NULL OR
     aprox IS NOT NULL OR
     priority IS NOT NULL OR
     cut IS NOT NULL OR
index a757345..ce54ebc 100644 (file)
@@ -16055,6 +16055,14 @@ INSERT INTO config.best_hold_order (
     1, 2, 3, 4, 5, 6, 7, 8
 );
 
+INSERT INTO config.best_hold_order (
+    name,
+    owning_lib_to_home_lib_prox, hprox, approx, pprox, aprox, priority, cut, depth, rtime
+) VALUES (
+    'Traditional with Holds-chase-home-lib-patrons',
+    1, 2, 3, 4, 5, 6, 7, 8, 9
+);
+
 INSERT INTO actor.org_unit_setting (
     org_unit, name, value
 ) VALUES (
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.hpprox-best-hold-sort-order b/Open-ILS/src/sql/Pg/upgrade/XXXX.hpprox-best-hold-sort-order
new file mode 100755 (executable)
index 0000000..3d8555b
--- /dev/null
@@ -0,0 +1,30 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE config.best_hold_order ADD COLUMN owning_lib_to_home_lib_prox INT; -- copy owning lib <-> user home lib prox
+
+ALTER table config.best_hold_order DROP CONSTRAINT best_hold_order_check;
+
+-- At least one of these columns must contain a non-null value
+ALTER TABLE config.best_hold_order ADD CHECK ((
+    pprox IS NOT NULL OR
+    hprox IS NOT NULL OR
+    owning_lib_to_home_lib_prox IS NOT NULL OR
+    aprox IS NOT NULL OR
+    priority IS NOT NULL OR
+    cut IS NOT NULL OR
+    depth IS NOT NULL OR
+    htime IS NOT NULL OR
+    rtime IS NOT NULL
+));
+
+INSERT INTO config.best_hold_order (
+    name,
+    owning_lib_to_home_lib_prox, hprox, approx, pprox, aprox, priority, cut, depth, rtime
+) VALUES (
+    'Traditional with Holds-chase-home-lib-patrons',
+    1, 2, 3, 4, 5, 6, 7, 8, 9
+);
+
+COMMIT;
index 52d2862..e4fd1c7 100644 (file)
@@ -114,8 +114,9 @@ if (!dojo._hasResource["openils.conify.BestHoldOrder"]) {
     /* We could get these from the IDL, but if we add more fields to that
      * later, we have no particular mechanism for determining what is or
      * isn't metadata. */
-    module.fields = ["pprox", "hprox", "aprox", "priority", "cut", "depth",
-        "htime", "rtime", "approx", "shtime"];
+    module.fields = ["pprox", "hprox", "owning_lib_to_home_lib_prox",
+        "aprox", "priority", "cut", "depth", "htime", "rtime", "approx",
+        "shtime"];
 
     module.init = function() {
         module.progress_dialog = dijit.byId("progress-dialog");
diff --git a/docs/RELEASE_NOTES_NEXT/Circulation/hold-sort-order-chase-home-lib-patrons.adoc b/docs/RELEASE_NOTES_NEXT/Circulation/hold-sort-order-chase-home-lib-patrons.adoc
new file mode 100644 (file)
index 0000000..4d683cb
--- /dev/null
@@ -0,0 +1,5 @@
+New Hold Sort Order: Traditional with Holds-chase-home-lib-patrons
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This is a new entry under Administration -> Server Administration -> Best-Hold Selection Sort Order in the staff client.  It prioritizes holds such that a given item, based on its owning library, will prefer patrons with a matching home library, no matter the pickup library.
+
index 4670966..2778804 100644 (file)
@@ -99,6 +99,7 @@ CREATE TABLE config.best_hold_order(
     name        TEXT        UNIQUE,   -- i18n (metadata)
     pprox       INT, -- copy capture <-> pickup lib prox
     hprox       INT, -- copy circ lib <-> request lib prox
+    owning_lib_to_home_lib_prox      INT, -- copy owning lib <-> user home lib prox
     aprox       INT, -- copy circ lib <-> pickup lib ADJUSTED prox on ahcm
     priority    INT, -- group hold priority
     cut         INT, -- cut-in-line
@@ -111,6 +112,7 @@ CREATE TABLE config.best_hold_order(
 ALTER TABLE config.best_hold_order ADD CHECK ((
     pprox IS NOT NULL OR
     hprox IS NOT NULL OR
+    owning_lib_to_home_lib_prox IS NOT NULL OR
     aprox IS NOT NULL OR
     priority IS NOT NULL OR
     cut IS NOT NULL OR
@@ -167,6 +169,14 @@ INSERT INTO config.best_hold_order (
     1, 2, 3, 4, 5, 6, 7, 8
 );
 
+INSERT INTO config.best_hold_order (
+    name,
+    owning_lib_to_home_lib_prox, hprox, approx, pprox, aprox, priority, cut, depth, rtime
+) VALUES (
+    'Traditional with Holds-chase-home-lib-patrons',
+    1, 2, 3, 4, 5, 6, 7, 8, 9
+);
+
 INSERT INTO config.org_unit_setting_type (
     name, label, description, datatype, fm_class, update_perm
 ) VALUES (