LP#1795906: new global flag to toggle use of pickup lib in hold queue calculation user/gmcharlt/lp1795906_hold_queue_position
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 Oct 2018 19:33:03 +0000 (15:33 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 Oct 2018 19:33:03 +0000 (15:33 -0400)
This patch adds a new global flag, circ.holds.queue_position_relative_to_pickup_lib,
to control whether or not the pickup library is used to restrict the set of
holds constituting the queue that a given hold belongs to. When this flag is
enabled (as it is by default), the queue includes only holds with the same
pickup library. If the flag is not enabled, the previous behavior of including
all relevant holds in the entire consortium is used instead.

This flag is provided in cases where material is broadly shared among the
entire consortium and few of the options to have holds prefer to be
filled locally are in force. In that case, to display a queue position
relative to the pickup library may cause patrons to think that their
requests will be filled significantly sooner than they should expect.

To test
-------
[1] Create five holds on one title for five different patrons, with the
    first with pickup library BR1 and the last with pickup library BR2.
[2] View the hold in the My Account page for the fifth patron. The hold
    should display as #5.
[3] Apply the patch and repeat step 2. The hold should display as #1.
[4] Disable the new global flag. The hold should display as #5 again.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql

index 1cc1f9b..4109948 100644 (file)
@@ -1363,7 +1363,22 @@ sub retrieve_hold_queue_status_impl {
     # The holds queue is defined as the distinct set of holds that share at
     # least one potential copy with the context hold, plus any holds that
     # share the same hold type and target.  The latter part exists to
-    # accomodate holds that currently have no potential copies
+    # accomodate holds that currently have no potential copies.
+    #
+    # The global flag circ.holds.queue_position_relative_to_pickup_lib
+    # controls whether or not to restrict that set of holds to the
+    # ones that also share the same pickup library. Restricting the set
+    # to the pickup library offers a modest performance benefit and
+    # makes the queue position in the public catalog match the position
+    # displayed in the staff hold shelf list. However, if resources
+    # are shared across the entire consortium, a pickup-library-restricted
+    # queue position may make patrons think that they are going to
+    # get their materials sooner than they should expect; this is why
+    # the global flag is provided.
+
+    my $relative_to_pickup_lib = $e->retrieve_config_global_flag('circ.holds.queue_position_relative_to_pickup_lib');
+    $relative_to_pickup_lib = ($relative_to_pickup_lib and $U->is_true($relative_to_pickup_lib->enabled));
+
     my $q_holds = $e->json_query({
 
         # fetch cut_in_line and request_time since they're in the order_by
@@ -1371,7 +1386,7 @@ sub retrieve_hold_queue_status_impl {
         select => {ahr => ['id', 'cut_in_line', 'request_time']},
         from   => 'ahr',
         where => {
-            pickup_lib => $hold->pickup_lib,
+            ($relative_to_pickup_lib) ? ( pickup_lib => $hold->pickup_lib ) : (),
             id => { in => {
                 select => { ahcm => ['hold'] },
                 from   => {
@@ -1415,7 +1430,7 @@ sub retrieve_hold_queue_status_impl {
                 { "class" => "ahr", "field" => "request_time" }
             ],
             where    => {
-                pickup_lib => $hold->pickup_lib,
+                ($relative_to_pickup_lib) ? ( pickup_lib => $hold->pickup_lib ) : (),
                 hold_type => $hold->hold_type,
                 target    => $hold->target,
                 capture_time => undef,
index 949021b..61f7e37 100644 (file)
@@ -19413,5 +19413,13 @@ VALUES (
     )
 );
 
-
-
+INSERT INTO config.global_flag (name, label, enabled) VALUES (
+    'circ.holds.queue_position_relative_to_pickup_lib',
+    oils_i18n_gettext(
+        'circ.holds.queue_position_relative_to_pickup_lib',
+        'Calculate hold queue position relative to pickup library (as opposed to entire consortium)',
+        'cgf',
+        'label'
+    ),
+    TRUE
+);