[GIT] Evergreen ILS branch rel_3_14 updated. 1997324a0167ef67848e29d8bc72cb132dedd78b

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_14 has been updated via 1997324a0167ef67848e29d8bc72cb132dedd78b (commit) via 7e0e48cacf1c0f0ddf3fe61d6371466fa8c3a738 (commit) via 21bd2cdf1ab5d99afddc0a3476ae24535ed188e3 (commit) from b364ba7de62d6d0ad562ff6a07c74170b62a937b (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 1997324a0167ef67848e29d8bc72cb132dedd78b Author: Jane Sandberg <sandbergja@gmail.com> Date: Thu Jun 19 09:40:44 2025 -0700 LP#1848375: stamp upgrade script Signed-off-by: Jane Sandberg <sandbergja@gmail.com> diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 0b22ef1a4d..e3f7bebb66 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 ('1471', :eg_version); -- miker/sandbergja +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1474', :eg_version); -- jeffdavis/gmcharlt/sandbergja CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.vandelay.auto_overlay_org_unit_copies.sql b/Open-ILS/src/sql/Pg/upgrade/1474.schema.vandelay.auto_overlay_org_unit_copies.sql similarity index 97% rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.vandelay.auto_overlay_org_unit_copies.sql rename to Open-ILS/src/sql/Pg/upgrade/1474.schema.vandelay.auto_overlay_org_unit_copies.sql index 79d729de87..24bc1ed856 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.vandelay.auto_overlay_org_unit_copies.sql +++ b/Open-ILS/src/sql/Pg/upgrade/1474.schema.vandelay.auto_overlay_org_unit_copies.sql @@ -1,6 +1,6 @@ BEGIN; -SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); +SELECT evergreen.upgrade_deps_block_check('1474', :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 commit 7e0e48cacf1c0f0ddf3fe61d6371466fa8c3a738 Author: Jane Sandberg <sandbergja@gmail.com> Date: Thu Jun 19 09:36:58 2025 -0700 LP#1848375: follow-up: add a pgtap test I wrote a test to help me wrap my mind around the infinite loop. I'm checking it in in case it helps others to understand the function or prevents regressions. Signed-off-by: Jane Sandberg <sandbergja@gmail.com> diff --git a/Open-ILS/src/sql/Pg/live_t/lp1848375_marc_import_auto_overlay.pg b/Open-ILS/src/sql/Pg/live_t/lp1848375_marc_import_auto_overlay.pg new file mode 100644 index 0000000000..af57928482 --- /dev/null +++ b/Open-ILS/src/sql/Pg/live_t/lp1848375_marc_import_auto_overlay.pg @@ -0,0 +1,33 @@ +BEGIN; + +SELECT plan(1); + +-- The function under test previously had an infinite loop, which makes for a very +-- boring test-running experience. For this db session only, set a time limit of +-- 5 seconds. +SET statement_timeout = 5000; + +-- Create a queue +INSERT INTO vandelay.bib_queue (id, owner, name) VALUES (5555, 7, 'lp1848375 test bucket'); + +-- Enqueue a bib record and an item that matches a record in the collection +INSERT INTO vandelay.queued_bib_record(id, marc, queue) VALUES (7777, '<record><datafield tag="901" ind1=" " ind2=" "><subfield code="c">243</subfield></datafield></record>', 5555); +INSERT INTO vandelay.import_item (record, definition, owning_lib) VALUES ( + 7777, + 1, -- Evergreen holdings format + 9 -- Bookmobile 1, which already has some copies of bib record 243 +); + +PREPARE auto_overlay_with_items AS SELECT vandelay.auto_overlay_org_unit_copies( + 7777, + 2, -- full overlay + 0 -- quality ratio +); + +SELECT performs_ok( + 'auto_overlay_with_items', + 1000, + 'overlaying a record with items takes less than a second' +); + +ROLLBACK; commit 21bd2cdf1ab5d99afddc0a3476ae24535ed188e3 Author: Jeff Davis <jdavis@sitka.bclibraries.ca> Date: Wed Oct 16 12:29:25 2019 -0700 LP#1848375: finesse while loop on vandelay.auto_overlay_org_unit_copies Release-note: Fixes bug where MARC import with items might never finish when "Use Org Unit Matching in Copy to Determine Best Match" is in effect Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca> Signed-off-by: Galen Charlton <gmc@equinoxOLI.org> Signed-off-by: Jane Sandberg <sandbergja@gmail.com> diff --git a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql index 77423e8182..0d4818f9de 100644 --- a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql +++ b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql @@ -1916,7 +1916,8 @@ BEGIN FROM vandelay.import_item WHERE record = import_id; - WHILE CARDINALITY(scope_orgs) > 0 LOOP + WHILE CARDINALITY(scope_orgs) IS NOT NULL LOOP + EXIT WHEN CARDINALITY(scope_orgs) = 0; 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 @@ -1938,12 +1939,15 @@ BEGIN END LOOP; END LOOP; + EXIT WHEN eg_id IS NOT NULL; + -- 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; + EXIT WHEN CARDINALITY(scope_orgs) IS NULL; END IF; END LOOP; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.vandelay.auto_overlay_org_unit_copies.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.vandelay.auto_overlay_org_unit_copies.sql new file mode 100644 index 0000000000..79d729de87 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.vandelay.auto_overlay_org_unit_copies.sql @@ -0,0 +1,79 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :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) IS NOT NULL LOOP + EXIT WHEN CARDINALITY(scope_orgs) = 0; + 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; + + EXIT WHEN eg_id IS NOT NULL; + + -- 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; + EXIT WHEN CARDINALITY(scope_orgs) IS 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; ----------------------------------------------------------------------- Summary of changes: Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/012.schema.vandelay.sql | 6 +++- .../live_t/lp1848375_marc_import_auto_overlay.pg | 33 ++++++++++++++++++++++ ...hema.vandelay.auto_overlay_org_unit_copies.sql} | 8 ++++-- 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/live_t/lp1848375_marc_import_auto_overlay.pg copy Open-ILS/src/sql/Pg/upgrade/{1186.schema.fix_auto_overlay_org_unit_copies.sql => 1474.schema.vandelay.auto_overlay_org_unit_copies.sql} (91%) hooks/post-receive -- Evergreen ILS
participants (1)
-
Git User