[open-ils-commits] [GIT] Evergreen ILS branch master updated. be77be6102c4bf392704ea5742e56d85e84edd3b
Evergreen Git
git at git.evergreen-ils.org
Tue Oct 1 16:55:58 EDT 2019
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 be77be6102c4bf392704ea5742e56d85e84edd3b (commit)
via f7c0d356fd68639ebb094aeaf4b2a54b54fdbecb (commit)
from fafd2dca8f9c8d0e0d98428747174d8a0953ad2b (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 be77be6102c4bf392704ea5742e56d85e84edd3b
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date: Tue Oct 1 16:54:39 2019 -0400
LP#1845260: add additional DB update to be sure
... that the function is correct if somebody is upgrading a
beta1 or beta2 database.
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 54d01e4874..b91c7d7778 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 ('1184', :eg_version); -- cesardv/phasefx/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1185', :eg_version); -- jeffdavis/gmcharlt
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1186.schema.fix_auto_overlay_org_unit_copies.sql b/Open-ILS/src/sql/Pg/upgrade/1186.schema.fix_auto_overlay_org_unit_copies.sql
new file mode 100644
index 0000000000..96fc6d7b46
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/1186.schema.fix_auto_overlay_org_unit_copies.sql
@@ -0,0 +1,75 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1186', :eg_version);
+
+CREATE OR REPLACE FUNCTION vandelay.auto_overlay_org_unit_copies ( import_id BIGINT, merge_profile_id INT, lwm_ratio_value_p NUMERIC ) RETURNS BOOL AS $$
+DECLARE
+ eg_id BIGINT;
+ match_count INT;
+ rec vandelay.bib_match%ROWTYPE;
+ v_owning_lib INT;
+ scope_org INT;
+ scope_orgs INT[];
+ copy_count INT := 0;
+ max_copy_count INT := 0;
+BEGIN
+
+ PERFORM * FROM vandelay.queued_bib_record WHERE import_time IS NOT NULL AND id = import_id;
+
+ IF FOUND THEN
+ -- RAISE NOTICE 'already imported, cannot auto-overlay'
+ RETURN FALSE;
+ END IF;
+
+ -- Gather all the owning libs for our import items.
+ -- These are our initial scope_orgs.
+ SELECT ARRAY_AGG(DISTINCT owning_lib) INTO scope_orgs
+ FROM vandelay.import_item
+ WHERE record = import_id;
+
+ WHILE CARDINALITY(scope_orgs) > 0 LOOP
+ FOR scope_org IN SELECT * FROM UNNEST(scope_orgs) LOOP
+ -- For each match, get a count of all copies at descendants of our scope org.
+ FOR rec IN SELECT * FROM vandelay.bib_match AS vbm
+ WHERE queued_record = import_id
+ ORDER BY vbm.eg_record DESC
+ LOOP
+ SELECT COUNT(acp.id) INTO copy_count
+ FROM asset.copy AS acp
+ INNER JOIN asset.call_number AS acn
+ ON acp.call_number = acn.id
+ WHERE acn.owning_lib IN (SELECT id FROM
+ actor.org_unit_descendants(scope_org))
+ AND acn.record = rec.eg_record
+ AND acp.deleted = FALSE;
+ IF copy_count > max_copy_count THEN
+ max_copy_count := copy_count;
+ eg_id := rec.eg_record;
+ END IF;
+ END LOOP;
+ END LOOP;
+
+ -- If no matching bibs had holdings, gather our next set of orgs to check, and iterate.
+ IF max_copy_count = 0 THEN
+ SELECT ARRAY_AGG(DISTINCT parent_ou) INTO scope_orgs
+ FROM actor.org_unit
+ WHERE id IN (SELECT * FROM UNNEST(scope_orgs))
+ AND parent_ou IS NOT NULL;
+ END IF;
+ END LOOP;
+
+ IF eg_id IS NULL THEN
+ -- Could not determine best match via copy count
+ -- fall back to default best match
+ IF (SELECT * FROM vandelay.auto_overlay_bib_record_with_best( import_id, merge_profile_id, lwm_ratio_value_p )) THEN
+ RETURN TRUE;
+ ELSE
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ RETURN vandelay.overlay_bib_record( import_id, eg_id, merge_profile_id );
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMIT;
commit f7c0d356fd68639ebb094aeaf4b2a54b54fdbecb
Author: Jeff Davis <jdavis at sitka.bclibraries.ca>
Date: Mon Sep 23 16:15:14 2019 -0700
LP#1845260: fix error in vandelay.auto_overlay_org_unit_copies db function
Signed-off-by: Jeff Davis <jdavis at sitka.bclibraries.ca>
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
diff --git a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
index 732be40a6d..64fd6cdb15 100644
--- a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
+++ b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
@@ -1885,7 +1885,7 @@ BEGIN
-- These are our initial scope_orgs.
SELECT ARRAY_AGG(DISTINCT owning_lib) INTO scope_orgs
FROM vandelay.import_item
- WHERE queued_record = import_id;
+ WHERE record = import_id;
WHILE CARDINALITY(scope_orgs) > 0 LOOP
FOR scope_org IN SELECT * FROM UNNEST(scope_orgs) LOOP
diff --git a/Open-ILS/src/sql/Pg/upgrade/1182.schema.vandelay.auto_overlay_org_unit_copies.sql b/Open-ILS/src/sql/Pg/upgrade/1182.schema.vandelay.auto_overlay_org_unit_copies.sql
index 13816a30bc..70a4b3e11b 100644
--- a/Open-ILS/src/sql/Pg/upgrade/1182.schema.vandelay.auto_overlay_org_unit_copies.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1182.schema.vandelay.auto_overlay_org_unit_copies.sql
@@ -31,7 +31,7 @@ BEGIN
-- These are our initial scope_orgs.
SELECT ARRAY_AGG(DISTINCT owning_lib) INTO scope_orgs
FROM vandelay.import_item
- WHERE queued_record = import_id;
+ WHERE record = import_id;
WHILE CARDINALITY(scope_orgs) > 0 LOOP
FOR scope_org IN SELECT * FROM UNNEST(scope_orgs) LOOP
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/012.schema.vandelay.sql | 2 +-
.../1182.schema.vandelay.auto_overlay_org_unit_copies.sql | 2 +-
...es.sql => 1186.schema.fix_auto_overlay_org_unit_copies.sql} | 10 ++--------
4 files changed, 5 insertions(+), 11 deletions(-)
copy Open-ILS/src/sql/Pg/upgrade/{1182.schema.vandelay.auto_overlay_org_unit_copies.sql => 1186.schema.fix_auto_overlay_org_unit_copies.sql} (83%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list