Holds-go-home's key determinant, htime, has bug
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 3 Apr 2013 20:35:51 +0000 (16:35 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 5 Apr 2013 14:41:40 +0000 (10:41 -0400)
Should compare checkin lib to copy's (call number's) owning_lib, not
hold request lib.

You might think the comparison should be to acp.circ_lib, but that
doesn't work with floating copies (for non-floaters, acp.circ_lib
should be equal to acp.call_number.owning_lib).

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm

index baa7098..c0c953b 100644 (file)
@@ -30,14 +30,14 @@ my %HOLD_SORT_ORDER_BY = (
     htime => q!
         CASE WHEN
             copy_has_not_been_home.result
-        THEN actor.org_unit_proximity(%d, h.request_lib)
+        THEN actor.org_unit_proximity(%d, acn.owning_lib)
         ELSE 999
         END
     !,
     shtime => q!
         CASE WHEN
             copy_has_not_been_home_even_to_idle.result
-        THEN actor.org_unit_proximity(%d, h.request_lib)
+        THEN actor.org_unit_proximity(%d, acn.owning_lib)
         ELSE 999
         END
     !,
@@ -413,7 +413,12 @@ sub build_hold_sort_clause {
             )
     ) AS result
 ) !, $cp->id, $cp->circ_lib, $cp->circ_lib, $cp->id);
-        $joins .= " JOIN copy_has_not_been_home ON (true) ";
+
+        $joins .= q!
+            JOIN copy_has_not_been_home ON (true)
+            JOIN asset.copy acp ON (hm.target_copy = acp.id)
+            JOIN asset.call_number acn ON (acn.id = acp.call_number)
+        !;
     }
 
     if ($ctes_needed == 2) {