[open-ils-commits] [GIT] Evergreen ILS branch master updated. d967aac09b076d5782047357b5dfcad4b7f1fe9a

Evergreen Git git at git.evergreen-ils.org
Wed Aug 15 18:12:05 EDT 2018


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  d967aac09b076d5782047357b5dfcad4b7f1fe9a (commit)
       via  327daf4e40f171b442a700f355c473f48177fffb (commit)
       via  aa1d5603aacfb37e3559fb6145ba0327c9f6b1a6 (commit)
       via  fe474209a567559491343dd6d8bccc8c3f2d9a2d (commit)
       via  9b4591e3f9f88aa335c2ba6d4e928ca6fbc879da (commit)
      from  4e0528b11a244734b0d2835dd8ce6c96fb28a5fd (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 d967aac09b076d5782047357b5dfcad4b7f1fe9a
Author: Kathy Lussier <klussier at masslnc.org>
Date:   Wed Aug 15 18:10:08 2018 -0400

    LP#1775216: Stamping upgrade script for inconsistent copy counts
    
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 728d937..e420874 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -92,7 +92,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1118', :eg_version); -- gmcharlt/berick
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1119', :eg_version); -- idjit/kmlussier
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql b/Open-ILS/src/sql/Pg/upgrade/1119.schema.lp1775216_consistent_avail_counts.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
rename to Open-ILS/src/sql/Pg/upgrade/1119.schema.lp1775216_consistent_avail_counts.sql
index 2b069f3..66252eb 100644
--- a/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1119.schema.lp1775216_consistent_avail_counts.sql
@@ -1,3 +1,5 @@
+SELECT evergreen.upgrade_deps_block_check('1119', :eg_version);
+
 CREATE OR REPLACE FUNCTION asset.staff_ou_record_copy_count(org integer, rid bigint)
  RETURNS TABLE(depth integer, org_unit integer, visible bigint, available bigint, unshadow bigint, transcendant integer)
  LANGUAGE plpgsql

commit 327daf4e40f171b442a700f355c473f48177fffb
Author: a. bellenir <ab at grpl.org>
Date:   Fri Jun 15 15:53:10 2018 -0400

    LP#1587620: inconsistent copy counts between opac and staff client for peer bibs
    
    staff copy counts should include peer bib copies, per LP1587620.
    
    Signed-off-by: a. bellenir <ab at grpl.org>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql
index 79aa442..04d98b3 100644
--- a/Open-ILS/src/sql/Pg/040.schema.asset.sql
+++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql
@@ -617,39 +617,53 @@ BEGIN
 END;            
 $f$ LANGUAGE PLPGSQL;
 
-CREATE OR REPLACE FUNCTION asset.staff_ou_record_copy_count (org INT, rid BIGINT) RETURNS TABLE (depth INT, org_unit INT, visible BIGINT, available BIGINT, unshadow BIGINT, transcendant INT) AS $f$
-DECLARE         
-    ans RECORD; 
+CREATE OR REPLACE FUNCTION asset.staff_ou_record_copy_count(org integer, rid bigint)
+ RETURNS TABLE(depth integer, org_unit integer, visible bigint, available bigint, unshadow bigint, transcendant integer)
+ LANGUAGE plpgsql
+AS $function$
+DECLARE
+    ans RECORD;
     trans INT;
-BEGIN           
+BEGIN
     SELECT 1 INTO trans FROM biblio.record_entry b JOIN config.bib_source src ON (b.source = src.id) WHERE src.transcendant AND b.id = rid;
 
     FOR ans IN SELECT u.id, t.depth FROM actor.org_unit_ancestors(org) AS u JOIN actor.org_unit_type t ON (u.ou_type = t.id) LOOP
         RETURN QUERY
-        WITH available_statuses AS (SELECT ARRAY_AGG(id) AS ids FROM config.copy_status WHERE is_available)
-        SELECT  ans.depth,
-                ans.id,
-                COUNT( cp.id ),
-                SUM( (cp.status = ANY (available_statuses.ids))::INT ),
-                SUM( CASE WHEN cl.opac_visible AND cp.opac_visible THEN 1 ELSE 0 END),
-                trans
-          FROM
-                available_statuses,
-                actor.org_unit_descendants(ans.id) d
-                JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted)
-                JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)
-                JOIN asset.call_number cn ON (cn.record = rid AND cn.id = cp.call_number AND NOT cn.deleted)
-          GROUP BY 1,2,6;
+        WITH available_statuses AS (SELECT ARRAY_AGG(id) AS ids FROM config.copy_status WHERE is_available),
+            cp AS(
+                SELECT  cp.id,
+                        (cp.status = ANY (available_statuses.ids))::INT as available,
+                        (cl.opac_visible AND cp.opac_visible)::INT as opac_visible
+                  FROM
+                        available_statuses,
+                        actor.org_unit_descendants(ans.id) d
+                        JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted)
+                        JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)
+                        JOIN asset.call_number cn ON (cn.record = rid AND cn.id = cp.call_number AND NOT cn.deleted)
+            ),
+            peer AS (
+                select  cp.id,
+                        (cp.status = ANY  (available_statuses.ids))::INT as available,
+                        (cl.opac_visible AND cp.opac_visible)::INT as opac_visible
+                FROM
+                        available_statuses,
+                        actor.org_unit_descendants(ans.id) d
+                        JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted)
+                        JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)
+                        JOIN biblio.peer_bib_copy_map bp ON (bp.peer_record = rid AND bp.target_copy = cp.id)
+            )
+        select ans.depth, ans.id, count(id), sum(x.available::int), sum(x.opac_visible::int), trans
+        from ((select * from cp) union (select * from peer)) x
+        group by 1,2,6;
 
         IF NOT FOUND THEN
             RETURN QUERY SELECT ans.depth, ans.id, 0::BIGINT, 0::BIGINT, 0::BIGINT, trans;
         END IF;
 
     END LOOP;
-
     RETURN;
 END;
-$f$ LANGUAGE PLPGSQL;
+$function$;
 
 CREATE OR REPLACE FUNCTION asset.staff_lasso_record_copy_count (i_lasso INT, rid BIGINT) RETURNS TABLE (depth INT, org_unit INT, visible BIGINT, available BIGINT, unshadow BIGINT, transcendant INT) AS $f$
 DECLARE
diff --git a/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql b/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
index b4d36c5..2b069f3 100644
--- a/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
@@ -10,27 +10,38 @@ BEGIN
 
     FOR ans IN SELECT u.id, t.depth FROM actor.org_unit_ancestors(org) AS u JOIN actor.org_unit_type t ON (u.ou_type = t.id) LOOP
         RETURN QUERY
-        WITH available_statuses AS (SELECT ARRAY_AGG(id) AS ids FROM config.copy_status WHERE is_available)
-        SELECT  ans.depth,
-                ans.id,
-                COUNT( cp.id ),
-                SUM( (cp.status = ANY (available_statuses.ids))::INT ),
-                SUM( CASE WHEN cl.opac_visible AND cp.opac_visible THEN 1 ELSE 0 END),
-                trans
-          FROM
-                available_statuses,
-                actor.org_unit_descendants(ans.id) d
-                JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted)
-                JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)
-                JOIN asset.call_number cn ON (cn.record = rid AND cn.id = cp.call_number AND NOT cn.deleted)
-          GROUP BY 1,2,6;
+        WITH available_statuses AS (SELECT ARRAY_AGG(id) AS ids FROM config.copy_status WHERE is_available),
+            cp AS(
+                SELECT  cp.id,
+                        (cp.status = ANY (available_statuses.ids))::INT as available,
+                        (cl.opac_visible AND cp.opac_visible)::INT as opac_visible
+                  FROM
+                        available_statuses,
+                        actor.org_unit_descendants(ans.id) d
+                        JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted)
+                        JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)
+                        JOIN asset.call_number cn ON (cn.record = rid AND cn.id = cp.call_number AND NOT cn.deleted)
+            ),
+            peer AS (
+                SELECT  cp.id,
+                        (cp.status = ANY  (available_statuses.ids))::INT as available,
+                        (cl.opac_visible AND cp.opac_visible)::INT as opac_visible
+                FROM
+                        available_statuses,
+                        actor.org_unit_descendants(ans.id) d
+                        JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted)
+                        JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)
+                        JOIN biblio.peer_bib_copy_map bp ON (bp.peer_record = rid AND bp.target_copy = cp.id)
+            )
+        SELECT ans.depth, ans.id, count(id), sum(x.available::int), sum(x.opac_visible::int), trans
+        FROM ((select * from cp) union (select * from peer)) x
+        GROUP BY 1,2,6;
 
         IF NOT FOUND THEN
             RETURN QUERY SELECT ans.depth, ans.id, 0::BIGINT, 0::BIGINT, 0::BIGINT, trans;
         END IF;
 
     END LOOP;
-
     RETURN;
 END;
 $function$;

commit aa1d5603aacfb37e3559fb6145ba0327c9f6b1a6
Author: a. bellenir <ab at grpl.org>
Date:   Fri Jun 8 11:42:53 2018 -0400

    LP#1775216: inconsistent copy counts between opac and staff client
    
    opac version of copy counts was including copies under deleted call numbers
    more discussion here: http://irc.evergreen-ils.org/evergreen/2018-06-08#i_363334
    
    Signed-off-by: a. bellenir <ab at grpl.org>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql
index 3206c29..79aa442 100644
--- a/Open-ILS/src/sql/Pg/040.schema.asset.sql
+++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql
@@ -568,6 +568,7 @@ BEGIN
                 org_list,
                 asset.copy_vis_attr_cache av
                 JOIN asset.copy cp ON (cp.id = av.target_copy AND av.record = rid)
+                JOIN asset.call_number cn ON (cp.call_number = cn.id AND not cn.deleted)
           WHERE cp.circ_lib = ANY (org_list.orgs) AND av.vis_attr_vector @@ mask.c_attrs::query_int
           GROUP BY 1,2,6;
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql b/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
index e76d09e..b4d36c5 100644
--- a/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
@@ -34,3 +34,44 @@ BEGIN
     RETURN;
 END;
 $function$;
+
+CREATE OR REPLACE FUNCTION asset.opac_ou_record_copy_count(org integer, rid bigint)
+ RETURNS TABLE(depth integer, org_unit integer, visible bigint, available bigint, unshadow bigint, transcendant integer)
+ LANGUAGE plpgsql
+AS $function$
+DECLARE
+    ans RECORD;
+    trans INT;
+BEGIN
+    SELECT 1 INTO trans FROM biblio.record_entry b JOIN config.bib_source src ON (b.source = src.id) WHERE src.transcendant AND b.id = rid;
+
+    FOR ans IN SELECT u.id, t.depth FROM actor.org_unit_ancestors(org) AS u JOIN actor.org_unit_type t ON (u.ou_type = t.id) LOOP
+        RETURN QUERY
+        WITH org_list AS (SELECT ARRAY_AGG(id)::BIGINT[] AS orgs FROM actor.org_unit_descendants(ans.id) x),
+             available_statuses AS (SELECT ARRAY_AGG(id) AS ids FROM config.copy_status WHERE is_available),
+             mask AS (SELECT c_attrs FROM asset.patron_default_visibility_mask() x)
+        SELECT  ans.depth,
+                ans.id,
+                COUNT( av.id ),
+                SUM( (cp.status = ANY (available_statuses.ids))::INT ),
+                COUNT( av.id ),
+                trans
+          FROM  mask,
+                available_statuses,
+                org_list,
+                asset.copy_vis_attr_cache av
+                JOIN asset.copy cp ON (cp.id = av.target_copy AND av.record = rid)
+                JOIN asset.call_number cn ON (cp.call_number = cn.id AND not cn.deleted)
+          WHERE cp.circ_lib = ANY (org_list.orgs) AND av.vis_attr_vector @@ mask.c_attrs::query_int
+          GROUP BY 1,2,6;
+
+        IF NOT FOUND THEN
+            RETURN QUERY SELECT ans.depth, ans.id, 0::BIGINT, 0::BIGINT, 0::BIGINT, trans;
+        END IF;
+
+    END LOOP;
+
+    RETURN;
+END;
+$function$;
+

commit fe474209a567559491343dd6d8bccc8c3f2d9a2d
Author: a. bellenir <ab at grpl.org>
Date:   Fri Jun 8 10:29:59 2018 -0400

    LP#1775216: adding a pgtap test for inconsistent availability counts
    
    Signed-off-by: a. bellenir <ab at grpl.org>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/t/lp1775216-inconsistent-available-counts.pg b/Open-ILS/src/sql/Pg/t/lp1775216-inconsistent-available-counts.pg
new file mode 100644
index 0000000..36b06b9
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/lp1775216-inconsistent-available-counts.pg
@@ -0,0 +1,35 @@
+BEGIN;
+
+select plan(2);
+
+--consider all statuses to be "available" and "opac visible"
+update config.copy_status set opac_visible = 't', is_available = 't';
+
+-- consider all copies / locations to be opac visible 
+-- (since we're comparing staff copy counts with opac counts)
+update asset.copy_location set opac_visible = 't';
+update asset.copy set opac_visible = 't';
+
+-- the lp bug started because of a hardcoded status list.
+-- make sure we have at least some items with other statuses.
+select isnt_empty(
+    'select id from asset.copy where status not in (0,7,12) and not deleted',
+    'cannot test: no suitable copies for comparison'
+);
+
+select is_empty(
+    '
+    with min_ou as (select min(id) as id from actor.org_unit)
+    select distinct(record)
+    from min_ou,
+        asset.copy cpy join asset.call_number cn on cpy.call_number = cn.id
+    where not cpy.deleted and cpy.status not in (0,7,12)
+        and (select available from asset.staff_ou_record_copy_count(min_ou.id, cn.record))
+            !=
+            (select available from asset.opac_ou_record_copy_count(min_ou.id, cn.record))
+    ','inconsistent available copy counts between staff client and opac'
+);
+
+SELECT * FROM finish();
+ROLLBACK;
+

commit 9b4591e3f9f88aa335c2ba6d4e928ca6fbc879da
Author: a. bellenir <ab at grpl.org>
Date:   Tue Jun 5 15:56:24 2018 -0400

    LP#1775216: inconsistent availability counts between staff client and opac
    
    update asset.staff_ou_record_copy_count to get an accurate available count.
    
    borrow asset.opac_ou_record_copy_count's logic for counting available copies
    so that statuses with is_available set to 't' in config.copy_status are used
    instead of using the hardcoded status id list (0,7,12)
    
    Signed-off-by: a. bellenir <ab at grpl.org>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql
index a7870aa..3206c29 100644
--- a/Open-ILS/src/sql/Pg/040.schema.asset.sql
+++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql
@@ -625,13 +625,15 @@ BEGIN
 
     FOR ans IN SELECT u.id, t.depth FROM actor.org_unit_ancestors(org) AS u JOIN actor.org_unit_type t ON (u.ou_type = t.id) LOOP
         RETURN QUERY
+        WITH available_statuses AS (SELECT ARRAY_AGG(id) AS ids FROM config.copy_status WHERE is_available)
         SELECT  ans.depth,
                 ans.id,
                 COUNT( cp.id ),
-                SUM( CASE WHEN cp.status IN (0,7,12) THEN 1 ELSE 0 END ),
+                SUM( (cp.status = ANY (available_statuses.ids))::INT ),
                 SUM( CASE WHEN cl.opac_visible AND cp.opac_visible THEN 1 ELSE 0 END),
                 trans
           FROM
+                available_statuses,
                 actor.org_unit_descendants(ans.id) d
                 JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted)
                 JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)
diff --git a/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql b/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
new file mode 100644
index 0000000..e76d09e
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/1112.schema.lp1775216_consistent_avail_counts.sql
@@ -0,0 +1,36 @@
+CREATE OR REPLACE FUNCTION asset.staff_ou_record_copy_count(org integer, rid bigint)
+ RETURNS TABLE(depth integer, org_unit integer, visible bigint, available bigint, unshadow bigint, transcendant integer)
+ LANGUAGE plpgsql
+AS $function$
+DECLARE
+    ans RECORD;
+    trans INT;
+BEGIN
+    SELECT 1 INTO trans FROM biblio.record_entry b JOIN config.bib_source src ON (b.source = src.id) WHERE src.transcendant AND b.id = rid;
+
+    FOR ans IN SELECT u.id, t.depth FROM actor.org_unit_ancestors(org) AS u JOIN actor.org_unit_type t ON (u.ou_type = t.id) LOOP
+        RETURN QUERY
+        WITH available_statuses AS (SELECT ARRAY_AGG(id) AS ids FROM config.copy_status WHERE is_available)
+        SELECT  ans.depth,
+                ans.id,
+                COUNT( cp.id ),
+                SUM( (cp.status = ANY (available_statuses.ids))::INT ),
+                SUM( CASE WHEN cl.opac_visible AND cp.opac_visible THEN 1 ELSE 0 END),
+                trans
+          FROM
+                available_statuses,
+                actor.org_unit_descendants(ans.id) d
+                JOIN asset.copy cp ON (cp.circ_lib = d.id AND NOT cp.deleted)
+                JOIN asset.copy_location cl ON (cp.location = cl.id AND NOT cl.deleted)
+                JOIN asset.call_number cn ON (cn.record = rid AND cn.id = cp.call_number AND NOT cn.deleted)
+          GROUP BY 1,2,6;
+
+        IF NOT FOUND THEN
+            RETURN QUERY SELECT ans.depth, ans.id, 0::BIGINT, 0::BIGINT, 0::BIGINT, trans;
+        END IF;
+
+    END LOOP;
+
+    RETURN;
+END;
+$function$;

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

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/040.schema.asset.sql           |   53 ++++++++----
 .../t/lp1775216-inconsistent-available-counts.pg   |   35 ++++++++
 ...19.schema.lp1775216_consistent_avail_counts.sql |   90 ++++++++++++++++++++
 4 files changed, 161 insertions(+), 19 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/t/lp1775216-inconsistent-available-counts.pg
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/1119.schema.lp1775216_consistent_avail_counts.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list