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

Evergreen Git git at git.evergreen-ils.org
Tue Nov 7 16:42:27 EST 2017


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  dfdd5a6d2e7de390e9c72cf96be79ac450356567 (commit)
       via  cbaca2a2ea253529e30a44161cd5ad0d5cc18d98 (commit)
       via  4adf54ae778f743d15b453473050c42887377b16 (commit)
       via  5a187c8148653e6b9d0fc32f10a008fa4069a603 (commit)
      from  ff0aa859e8069ba053efa23a55124ccd45ed212d (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 dfdd5a6d2e7de390e9c72cf96be79ac450356567
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Tue Nov 7 17:01:02 2017 -0500

    LP#1724246: stamp schema update
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 22eae9c..fa42ac4 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 ('1079', :eg_version); -- rhamby/cesardv/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1080', :eg_version); -- miker/jboyer/gmcharlt
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql b/Open-ILS/src/sql/Pg/upgrade/1080.schema.lp1724246_cache_copy_visibility.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql
rename to Open-ILS/src/sql/Pg/upgrade/1080.schema.lp1724246_cache_copy_visibility.sql
index 50a1392..0a57fb2 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1080.schema.lp1724246_cache_copy_visibility.sql
@@ -1,5 +1,7 @@
 BEGIN;
 
+SELECT evergreen.upgrade_deps_block_check('1080', :eg_version); -- miker/jboyer/gmcharlt
+
 CREATE OR REPLACE FUNCTION asset.cache_copy_visibility () RETURNS TRIGGER as $func$
 DECLARE
     ocn     asset.call_number%ROWTYPE;

commit cbaca2a2ea253529e30a44161cd5ad0d5cc18d98
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Tue Nov 7 16:29:48 2017 -0500

    LP#1724246: sync schema update script
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql
index d41596e..50a1392 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql
@@ -1,7 +1,5 @@
 BEGIN;
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1057', :eg_version); -- miker/gmcharlt/kmlussier
-
 CREATE OR REPLACE FUNCTION asset.cache_copy_visibility () RETURNS TRIGGER as $func$
 DECLARE
     ocn     asset.call_number%ROWTYPE;
@@ -71,6 +69,14 @@ BEGIN
                 UPDATE  biblio.record_entry
                   SET   vis_attr_vector = biblio.calculate_bib_visibility_attribute_set(ncn.record)
                   WHERE id = ocn.record;
+
+                -- We have to use a record-specific WHERE clause
+                -- to avoid modifying the entries for peer-bib copies.
+                UPDATE  asset.copy_vis_attr_cache
+                  SET   target_copy = NEW.id,
+                        record = ncn.record
+                  WHERE target_copy = OLD.id
+                        AND record = ocn.record;
             END IF;
         END IF;
 
@@ -79,9 +85,10 @@ BEGIN
            OLD.opac_visible <> NEW.opac_visible OR
            OLD.circ_lib     <> NEW.circ_lib
         THEN
-            -- any of these could change visibility, but
+            -- Any of these could change visibility, but
             -- we'll save some queries and not try to calculate
-            -- the change directly
+            -- the change directly.  We want to update peer-bib
+            -- entries in this case, unlike above.
             UPDATE  asset.copy_vis_attr_cache
               SET   target_copy = NEW.id,
                     vis_attr_vector = asset.calculate_copy_visibility_attribute_set(NEW.id)
@@ -137,4 +144,3 @@ END;
 $func$ LANGUAGE PLPGSQL;
 
 COMMIT;
-

commit 4adf54ae778f743d15b453473050c42887377b16
Author: Jason Boyer <JBoyer at library.in.gov>
Date:   Tue Oct 17 22:30:11 2017 -0500

    LP1724246: asset.cache_copy_visibility fix
    
    When removing peer bib copy maps the visibility
    cache wasn't updated correctly. This readjusts
    the cache trigger to correct that.
    
    Signed-off-by: Jason Boyer <JBoyer at library.in.gov>
    Signed-off-by: Mike Rylander <miker at esilibrary.com>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql
new file mode 100644
index 0000000..d41596e
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.lp1724246_cache_copy_visibility.sql
@@ -0,0 +1,140 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1057', :eg_version); -- miker/gmcharlt/kmlussier
+
+CREATE OR REPLACE FUNCTION asset.cache_copy_visibility () RETURNS TRIGGER as $func$
+DECLARE
+    ocn     asset.call_number%ROWTYPE;
+    ncn     asset.call_number%ROWTYPE;
+    cid     BIGINT;
+BEGIN
+
+    IF TG_TABLE_NAME = 'peer_bib_copy_map' THEN -- Only needs ON INSERT OR DELETE, so handle separately
+        IF TG_OP = 'INSERT' THEN
+            INSERT INTO asset.copy_vis_attr_cache (record, target_copy, vis_attr_vector) VALUES (
+                NEW.peer_record,
+                NEW.target_copy,
+                asset.calculate_copy_visibility_attribute_set(NEW.target_copy)
+            );
+
+            RETURN NEW;
+        ELSIF TG_OP = 'DELETE' THEN
+            DELETE FROM asset.copy_vis_attr_cache
+              WHERE record = OLD.peer_record AND target_copy = OLD.target_copy;
+
+            RETURN OLD;
+        END IF;
+    END IF;
+
+    IF TG_OP = 'INSERT' THEN -- Handles ON INSERT. ON UPDATE is below.
+        IF TG_TABLE_NAME IN ('copy', 'unit') THEN
+            SELECT * INTO ncn FROM asset.call_number cn WHERE id = NEW.call_number;
+            INSERT INTO asset.copy_vis_attr_cache (record, target_copy, vis_attr_vector) VALUES (
+                ncn.record,
+                NEW.id,
+                asset.calculate_copy_visibility_attribute_set(NEW.id)
+            );
+        ELSIF TG_TABLE_NAME = 'record_entry' THEN
+            NEW.vis_attr_vector := biblio.calculate_bib_visibility_attribute_set(NEW.id);
+        END IF;
+
+        RETURN NEW;
+    END IF;
+
+    -- handle items first, since with circulation activity
+    -- their statuses change frequently
+    IF TG_TABLE_NAME IN ('copy', 'unit') THEN -- This handles ON UPDATE OR DELETE. ON INSERT above
+
+        IF TG_OP = 'DELETE' THEN -- Shouldn't get here, normally
+            DELETE FROM asset.copy_vis_attr_cache WHERE target_copy = OLD.id;
+            RETURN OLD;
+        END IF;
+
+        SELECT * INTO ncn FROM asset.call_number cn WHERE id = NEW.call_number;
+
+        IF OLD.deleted <> NEW.deleted THEN
+            IF NEW.deleted THEN
+                DELETE FROM asset.copy_vis_attr_cache WHERE target_copy = OLD.id;
+            ELSE
+                INSERT INTO asset.copy_vis_attr_cache (record, target_copy, vis_attr_vector) VALUES (
+                    ncn.record,
+                    NEW.id,
+                    asset.calculate_copy_visibility_attribute_set(NEW.id)
+                );
+            END IF;
+
+            RETURN NEW;
+        ELSIF OLD.call_number  <> NEW.call_number THEN
+            SELECT * INTO ocn FROM asset.call_number cn WHERE id = OLD.call_number;
+
+            IF ncn.record <> ocn.record THEN
+                UPDATE  biblio.record_entry
+                  SET   vis_attr_vector = biblio.calculate_bib_visibility_attribute_set(ncn.record)
+                  WHERE id = ocn.record;
+            END IF;
+        END IF;
+
+        IF OLD.location     <> NEW.location OR
+           OLD.status       <> NEW.status OR
+           OLD.opac_visible <> NEW.opac_visible OR
+           OLD.circ_lib     <> NEW.circ_lib
+        THEN
+            -- any of these could change visibility, but
+            -- we'll save some queries and not try to calculate
+            -- the change directly
+            UPDATE  asset.copy_vis_attr_cache
+              SET   target_copy = NEW.id,
+                    vis_attr_vector = asset.calculate_copy_visibility_attribute_set(NEW.id)
+              WHERE target_copy = OLD.id;
+
+        END IF;
+
+    ELSIF TG_TABLE_NAME = 'call_number' THEN -- Only ON UPDATE. Copy handler will deal with ON INSERT OR DELETE.
+
+        IF OLD.record <> NEW.record THEN
+            IF NEW.label = '##URI##' THEN
+                UPDATE  biblio.record_entry
+                  SET   vis_attr_vector = biblio.calculate_bib_visibility_attribute_set(OLD.record)
+                  WHERE id = OLD.record;
+
+                UPDATE  biblio.record_entry
+                  SET   vis_attr_vector = biblio.calculate_bib_visibility_attribute_set(NEW.record)
+                  WHERE id = NEW.record;
+            END IF;
+
+            UPDATE  asset.copy_vis_attr_cache
+              SET   record = NEW.record,
+                    vis_attr_vector = asset.calculate_copy_visibility_attribute_set(target_copy)
+              WHERE target_copy IN (SELECT id FROM asset.copy WHERE call_number = NEW.id)
+                    AND record = OLD.record;
+
+        ELSIF OLD.owning_lib <> NEW.owning_lib THEN
+            UPDATE  asset.copy_vis_attr_cache
+              SET   vis_attr_vector = asset.calculate_copy_visibility_attribute_set(target_copy)
+              WHERE target_copy IN (SELECT id FROM asset.copy WHERE call_number = NEW.id)
+                    AND record = NEW.record;
+
+            IF NEW.label = '##URI##' THEN
+                UPDATE  biblio.record_entry
+                  SET   vis_attr_vector = biblio.calculate_bib_visibility_attribute_set(OLD.record)
+                  WHERE id = OLD.record;
+            END IF;
+        END IF;
+
+    ELSIF TG_TABLE_NAME = 'record_entry' THEN -- Only handles ON UPDATE OR DELETE
+
+        IF TG_OP = 'DELETE' THEN -- Shouldn't get here, normally
+            DELETE FROM asset.copy_vis_attr_cache WHERE record = OLD.id;
+            RETURN OLD;
+        ELSIF OLD.source <> NEW.source THEN
+            NEW.vis_attr_vector := biblio.calculate_bib_visibility_attribute_set(NEW.id);
+        END IF;
+
+    END IF;
+
+    RETURN NEW;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+COMMIT;
+

commit 5a187c8148653e6b9d0fc32f10a008fa4069a603
Author: Mike Rylander <miker at esilibrary.com>
Date:   Tue Nov 7 11:09:07 2017 -0500

    LP#1723977: Move no-LURIs test to be a peer of no-copies test
    
    The correct place to test the no-LURIs condition is as a peer to the
    no-copies test, when searching in staff mode.  We therefore move that
    test with this commit.
    
    In addition, the bib attribute vector may be null, in the case of a
    record with no bib source or LURI.  When testing emptiness we need to
    ask if the field IS NULL rather than just testing its contents.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Jason Boyer <JBoyer at library.in.gov>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
index f643d5f..1fb0c9f 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
@@ -1014,7 +1014,10 @@ sub toSQL {
 
         $final_c_attr_test = 'EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source AND vis_attr_vector @@ c_attr.vis_test)';
         if (!$pc_vis_test) { # staff search
-            $final_c_attr_test = '(' . $final_c_attr_test . ' OR NOT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source))';
+            $final_c_attr_test = '(' . $final_c_attr_test . " OR (" .
+                    "NOT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source) " .
+                    "AND (bre.vis_attr_vector IS NULL OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) ))".
+                "))";
         }
     }
  
@@ -1051,9 +1054,6 @@ sub toSQL {
 
         # These are magic numbers... see: search.calculate_visibility_attribute() UDF
         $final_b_attr_test = '(b_attr.vis_test IS NULL OR bre.vis_attr_vector @@ b_attr.vis_test)';
-        if (!$pb_vis_test) { # staff search
-            $final_b_attr_test .= " OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) )";
-        }
     }
 
     if ($final_c_attr_test or $final_b_attr_test) { # something...
diff --git a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
index 3349a45..8dabef9 100644
--- a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
+++ b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
@@ -593,7 +593,7 @@ BEGIN
             RETURN NEW;
         ELSIF TG_OP = 'DELETE' THEN
             DELETE FROM asset.copy_vis_attr_cache
-              WHERE record = NEW.peer_record AND target_copy = NEW.target_copy;
+              WHERE record = OLD.peer_record AND target_copy = OLD.target_copy;
 
             RETURN OLD;
         END IF;

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

Summary of changes:
 .../Application/Storage/Driver/Pg/QueryParser.pm   |    8 ++++----
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/300.schema.staged_search.sql   |    2 +-
 ...080.schema.lp1724246_cache_copy_visibility.sql} |    5 ++---
 4 files changed, 8 insertions(+), 9 deletions(-)
 copy Open-ILS/src/sql/Pg/upgrade/{1076.function.copy_vis_attr_cache_fixup.sql => 1080.schema.lp1724246_cache_copy_visibility.sql} (97%)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list