[open-ils-commits] [GIT] Evergreen ILS branch rel_3_0 updated. 0c891b46c348c9a36a5c2f2b6365a1359995fc24

Evergreen Git git at git.evergreen-ils.org
Wed Aug 15 18:19:18 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, rel_3_0 has been updated
       via  0c891b46c348c9a36a5c2f2b6365a1359995fc24 (commit)
       via  cb7107d1495e0b35ebfa1e90f24175c5d289f208 (commit)
       via  d2d075c699143384f3878a2b7eb09806fbab9ff6 (commit)
       via  25a25bc748bbdd1fcd8900c078e489e8c4363403 (commit)
       via  6b2a2db34489fcdf9250461119b333eecc52dff4 (commit)
      from  fd6eec4cc0dc07e1c8b2a21e954a466e64b9e79d (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 0c891b46c348c9a36a5c2f2b6365a1359995fc24
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>
    
    Conflicts:
    	Open-ILS/src/sql/Pg/002.schema.config.sql

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 335a312..3f0ce9a 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 ('1113', :eg_version); -- Dyrcona/csharp/miker
+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 cb7107d1495e0b35ebfa1e90f24175c5d289f208
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 7f1fb2f..0424a84 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 d2d075c699143384f3878a2b7eb09806fbab9ff6
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 3994b71..7f1fb2f 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 25a25bc748bbdd1fcd8900c078e489e8c4363403
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 6b2a2db34489fcdf9250461119b333eecc52dff4
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 f9948cb..3994b71 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