[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch master updated. 9a010a19dc2bde9a78c60aa50a9c5b0b32a996c8

Evergreen Git git at git.evergreen-ils.org
Thu Jan 16 15:24:23 EST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  9a010a19dc2bde9a78c60aa50a9c5b0b32a996c8 (commit)
       via  657e7f3826a5d0e8841bc4286ae37a49ec18c1ec (commit)
       via  a78bd1b91e5627a229658d71378157741b63b480 (commit)
      from  755547739123fa42676d9f6838de807c3875880b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9a010a19dc2bde9a78c60aa50a9c5b0b32a996c8
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Thu Jan 16 14:59:25 2014 -0500

    Test for Mike's proximity adjustment fix two commits back
    
    Being placed in Open-ILS/src/sql/Pg/live_t, the test requires stock and
    Concerto data be loaded.
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/live_t/XXXX.fixed_field_enhancements.pg b/Open-ILS/src/sql/Pg/live_t/XXXX.fixed_field_enhancements.pg
new file mode 100644
index 0000000..683be42
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/live_t/XXXX.fixed_field_enhancements.pg
@@ -0,0 +1,79 @@
+\set ECHO
+\set QUIET 1
+-- Turn off echo and keep things quiet.
+
+-- Format the output for nice TAP.
+\pset format unaligned
+\pset tuples_only true
+\pset pager
+
+-- Revert all changes on failure.
+\set ON_ERROR_ROLLBACK 1
+\set ON_ERROR_STOP true
+\set QUIET 1
+
+-- let's do this thing
+BEGIN;
+
+SELECT plan(7);
+
+-- The effect of this will be rolled back, so don't worry.
+DELETE FROM actor.org_unit_proximity_adjustment;
+
+-- Tests in the directory where we are rely on stock and Concerto data being
+-- loaded.
+INSERT INTO actor.org_unit_proximity_adjustment (
+    item_circ_lib, hold_pickup_lib, absolute_adjustment, prox_adjustment
+) VALUES (2, 2, true, 0);
+
+SELECT is(
+    (SELECT pickup_lib = 5 FROM action.hold_request WHERE id = 3),
+    TRUE,
+    'Data suitable for test: hold #3 has pickup_lib 5'
+);
+
+SELECT is(
+    (SELECT pickup_lib = 9 FROM action.hold_request WHERE id = 4),
+    TRUE,
+    'Data suitable for test: hold #4 has pickup_lib 9'
+);
+
+SELECT is(
+    (SELECT circ_lib = 4 FROM asset.copy WHERE id = 2884),
+    TRUE,
+    'Data suitable for test: copy #2884 has circ_lib 4'
+);
+
+SELECT is(
+    (SELECT aou.parent_ou = 2 AND aout.depth = 2
+        FROM actor.org_unit aou
+        JOIN actor.org_unit_type aout ON (aout.id = aou.ou_type)
+        WHERE aou.id = 5),
+    TRUE,
+    'Data suitable for test: ou #5 has parent_ou 2 and depth 2'
+);
+
+SELECT is(
+    (SELECT aou.parent_ou <> 2 AND aout.depth >= 2
+        FROM actor.org_unit aou
+        JOIN actor.org_unit_type aout ON (aout.id = aou.ou_type)
+        WHERE aou.id = 9),
+    TRUE,
+    'Data suitable for test: ou #9 doesn''t have parent_ou 2, does have depth at least 2'
+);
+        
+SELECT is(
+    action.hold_copy_calculated_proximity (3, 2884)::INT,
+    0,
+    'Org unit proximity adjustment takes effect when it should'
+);
+
+SELECT is(
+    action.hold_copy_calculated_proximity (4, 2884)::INT,
+    5,
+    '(regression test) Org unit proximity adjustment doesn''t take effect when it shouldn''t'
+);
+
+SELECT * FROM finish();
+ROLLBACK;
+

commit 657e7f3826a5d0e8841bc4286ae37a49ec18c1ec
Author: Mike Rylander <mrylander at gmail.com>
Date:   Thu Jan 16 14:11:34 2014 -0500

    Upgrade script
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.prox_adjust.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.prox_adjust.sql
new file mode 100644
index 0000000..aeb03ea
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.prox_adjust.sql
@@ -0,0 +1,95 @@
+BEGIN;
+
+CREATE OR REPLACE FUNCTION action.hold_copy_calculated_proximity(
+    ahr_id INT,
+    acp_id BIGINT,
+    copy_context_ou INT DEFAULT NULL
+    -- TODO maybe? hold_context_ou INT DEFAULT NULL.  This would optionally
+    -- support an "ahprox" measurement: adjust prox between copy circ lib and
+    -- hold request lib, but I'm unsure whether to use this theoretical
+    -- argument only in the baseline calculation or later in the other
+    -- queries in this function.
+) RETURNS NUMERIC AS $f$
+DECLARE
+    aoupa           actor.org_unit_proximity_adjustment%ROWTYPE;
+    ahr             action.hold_request%ROWTYPE;
+    acp             asset.copy%ROWTYPE;
+    acn             asset.call_number%ROWTYPE;
+    acl             asset.copy_location%ROWTYPE;
+    baseline_prox   NUMERIC;
+
+    icl_list        INT[];
+    iol_list        INT[];
+    isl_list        INT[];
+    hpl_list        INT[];
+    hrl_list        INT[];
+
+BEGIN
+
+    SELECT * INTO ahr FROM action.hold_request WHERE id = ahr_id;
+    SELECT * INTO acp FROM asset.copy WHERE id = acp_id;
+    SELECT * INTO acn FROM asset.call_number WHERE id = acp.call_number;
+    SELECT * INTO acl FROM asset.copy_location WHERE id = acp.location;
+
+    IF copy_context_ou IS NULL THEN
+        copy_context_ou := acp.circ_lib;
+    END IF;
+
+    -- First, gather the baseline proximity of "here" to pickup lib
+    SELECT prox INTO baseline_prox FROM actor.org_unit_proximity WHERE from_org = copy_context_ou AND to_org = ahr.pickup_lib;
+
+    -- Find any absolute adjustments, and set the baseline prox to that
+    SELECT  adj.* INTO aoupa
+      FROM  actor.org_unit_proximity_adjustment adj
+            LEFT JOIN actor.org_unit_ancestors_distance(copy_context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib)
+            LEFT JOIN actor.org_unit_ancestors_distance(acn.owning_lib) acn_ol ON (acn_ol.id = adj.item_owning_lib)
+            LEFT JOIN actor.org_unit_ancestors_distance(acl.owning_lib) acl_ol ON (acl_ol.id = adj.copy_location)
+            LEFT JOIN actor.org_unit_ancestors_distance(ahr.pickup_lib) ahr_pl ON (ahr_pl.id = adj.hold_pickup_lib)
+            LEFT JOIN actor.org_unit_ancestors_distance(ahr.request_lib) ahr_rl ON (ahr_rl.id = adj.hold_request_lib)
+      WHERE (adj.circ_mod IS NULL OR adj.circ_mod = acp.circ_modifier) AND
+            (adj.item_circ_lib IS NULL OR adj.item_circ_lib = acp_cl.id) AND
+            (adj.item_owning_lib IS NULL OR adj.item_owning_lib = acn_ol.id) AND
+            (adj.copy_location IS NULL OR adj.copy_location = acl_ol.id) AND
+            (adj.hold_pickup_lib IS NULL OR adj.hold_pickup_lib = ahr_pl.id) AND
+            (adj.hold_request_lib IS NULL OR adj.hold_request_lib = ahr_rl.id) AND
+            absolute_adjustment AND
+            COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL
+      ORDER BY
+            COALESCE(acp_cl.distance,999)
+                + COALESCE(acn_ol.distance,999)
+                + COALESCE(acl_ol.distance,999)
+                + COALESCE(ahr_pl.distance,999)
+                + COALESCE(ahr_rl.distance,999),
+            adj.pos
+      LIMIT 1;
+
+    IF FOUND THEN
+        baseline_prox := aoupa.prox_adjustment;
+    END IF;
+
+    -- Now find any relative adjustments, and change the baseline prox based on them
+    FOR aoupa IN
+        SELECT  adj.* 
+          FROM  actor.org_unit_proximity_adjustment adj
+                LEFT JOIN actor.org_unit_ancestors_distance(copy_context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib)
+                LEFT JOIN actor.org_unit_ancestors_distance(acn.owning_lib) acn_ol ON (acn_ol.id = adj.item_owning_lib)
+                LEFT JOIN actor.org_unit_ancestors_distance(acl.owning_lib) acl_ol ON (acn_ol.id = adj.copy_location)
+                LEFT JOIN actor.org_unit_ancestors_distance(ahr.pickup_lib) ahr_pl ON (ahr_pl.id = adj.hold_pickup_lib)
+                LEFT JOIN actor.org_unit_ancestors_distance(ahr.request_lib) ahr_rl ON (ahr_rl.id = adj.hold_request_lib)
+          WHERE (adj.circ_mod IS NULL OR adj.circ_mod = acp.circ_modifier) AND
+                (adj.item_circ_lib IS NULL OR adj.item_circ_lib = acp_cl.id) AND
+                (adj.item_owning_lib IS NULL OR adj.item_owning_lib = acn_ol.id) AND
+                (adj.copy_location IS NULL OR adj.copy_location = acl_ol.id) AND
+                (adj.hold_pickup_lib IS NULL OR adj.hold_pickup_lib = ahr_pl.id) AND
+                (adj.hold_request_lib IS NULL OR adj.hold_request_lib = ahr_rl.id) AND
+                NOT absolute_adjustment AND
+                COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL
+    LOOP
+        baseline_prox := baseline_prox + aoupa.prox_adjustment;
+    END LOOP;
+
+    RETURN baseline_prox;
+END;
+$f$ LANGUAGE PLPGSQL;
+
+COMMIT;

commit a78bd1b91e5627a229658d71378157741b63b480
Author: Mike Rylander <mrylander at gmail.com>
Date:   Thu Jan 16 13:58:12 2014 -0500

    Fix proximity adjustment calculator
    
    The canonical use case for proximity adjustment is to use it broadly
    to effect the local proximity of items within a particular area, in
    a like manner, across many parts of the org tree.  However, in cases
    where it is lightly used, or used with non-overlapping criteria columns,
    there are cases where the adjustment will spread beyond its intended
    range of influence.
    
    The changes here create a much stricter and correct test for rule
    matching, which will end in the correct choice of rules in all cases.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql
index e8aa81e..6ab9ab4 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -1291,12 +1291,17 @@ BEGIN
       FROM  actor.org_unit_proximity_adjustment adj
             LEFT JOIN actor.org_unit_ancestors_distance(copy_context_ou) acp_cl ON (acp_cl.id = adj.item_circ_lib)
             LEFT JOIN actor.org_unit_ancestors_distance(acn.owning_lib) acn_ol ON (acn_ol.id = adj.item_owning_lib)
-            LEFT JOIN actor.org_unit_ancestors_distance(acl.owning_lib) acl_ol ON (acn_ol.id = adj.copy_location)
+            LEFT JOIN actor.org_unit_ancestors_distance(acl.owning_lib) acl_ol ON (acl_ol.id = adj.copy_location)
             LEFT JOIN actor.org_unit_ancestors_distance(ahr.pickup_lib) ahr_pl ON (ahr_pl.id = adj.hold_pickup_lib)
             LEFT JOIN actor.org_unit_ancestors_distance(ahr.request_lib) ahr_rl ON (ahr_rl.id = adj.hold_request_lib)
       WHERE (adj.circ_mod IS NULL OR adj.circ_mod = acp.circ_modifier) AND
-        absolute_adjustment AND
-        COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL
+            (adj.item_circ_lib IS NULL OR adj.item_circ_lib = acp_cl.id) AND
+            (adj.item_owning_lib IS NULL OR adj.item_owning_lib = acn_ol.id) AND
+            (adj.copy_location IS NULL OR adj.copy_location = acl_ol.id) AND
+            (adj.hold_pickup_lib IS NULL OR adj.hold_pickup_lib = ahr_pl.id) AND
+            (adj.hold_request_lib IS NULL OR adj.hold_request_lib = ahr_rl.id) AND
+            absolute_adjustment AND
+            COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL
       ORDER BY
             COALESCE(acp_cl.distance,999)
                 + COALESCE(acn_ol.distance,999)
@@ -1320,8 +1325,13 @@ BEGIN
                 LEFT JOIN actor.org_unit_ancestors_distance(ahr.pickup_lib) ahr_pl ON (ahr_pl.id = adj.hold_pickup_lib)
                 LEFT JOIN actor.org_unit_ancestors_distance(ahr.request_lib) ahr_rl ON (ahr_rl.id = adj.hold_request_lib)
           WHERE (adj.circ_mod IS NULL OR adj.circ_mod = acp.circ_modifier) AND
-            NOT absolute_adjustment AND
-            COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL
+                (adj.item_circ_lib IS NULL OR adj.item_circ_lib = acp_cl.id) AND
+                (adj.item_owning_lib IS NULL OR adj.item_owning_lib = acn_ol.id) AND
+                (adj.copy_location IS NULL OR adj.copy_location = acl_ol.id) AND
+                (adj.hold_pickup_lib IS NULL OR adj.hold_pickup_lib = ahr_pl.id) AND
+                (adj.hold_request_lib IS NULL OR adj.hold_request_lib = ahr_rl.id) AND
+                NOT absolute_adjustment AND
+                COALESCE(acp_cl.id, acn_ol.id, acl_ol.id, ahr_pl.id, ahr_rl.id) IS NOT NULL
     LOOP
         baseline_prox := baseline_prox + aoupa.prox_adjustment;
     END LOOP;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/sql/Pg/090.schema.action.sql          |   20 ++++-
 .../sql/Pg/live_t/XXXX.fixed_field_enhancements.pg |   79 ++++++++++++++++++++
 ...ox_adjust.sql => XXXX.function.prox_adjust.sql} |   61 ++++-----------
 3 files changed, 109 insertions(+), 51 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/live_t/XXXX.fixed_field_enhancements.pg
 copy Open-ILS/src/sql/Pg/upgrade/{0759.schema.org_prox_adjust.sql => XXXX.function.prox_adjust.sql} (58%)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list