From: Bill Erickson Date: Mon, 13 Jun 2016 17:57:30 +0000 (-0400) Subject: LP#1588948 Auth propagate bib meta on change only X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d61a652d97339961fd4a65bf27c77f4bc1314ffb;p=evergreen%2Fmasslnc.git LP#1588948 Auth propagate bib meta on change only Only update bib record editor and edit_date if an authority record change propagation resulted in a modified bib record. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql index bbd76f8ccc..04b0b29125 100644 --- a/Open-ILS/src/sql/Pg/999.functions.global.sql +++ b/Open-ILS/src/sql/Pg/999.functions.global.sql @@ -1487,13 +1487,20 @@ CREATE OR REPLACE FUNCTION authority.propagate_changes (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$ DECLARE bib_rec biblio.record_entry%ROWTYPE; + new_marc TEXT; BEGIN SELECT INTO bib_rec * FROM biblio.record_entry WHERE id = bid; - bib_rec.marc := vandelay.merge_record_xml( + new_marc := vandelay.merge_record_xml( bib_rec.marc, authority.generate_overlay_template(aid)); + IF new_marc = bib_rec.marc THEN + -- Authority record change had no impact on this bib record. + -- Nothing left to do. + RETURN aid; + END IF; + PERFORM 1 FROM config.global_flag WHERE name = 'ingest.disable_authority_auto_update_bib_meta' AND enabled; @@ -1506,7 +1513,7 @@ BEGIN END IF; UPDATE biblio.record_entry SET - marc = bib_rec.marc, + marc = new_marc, editor = bib_rec.editor, edit_date = bib_rec.edit_date WHERE id = bid; diff --git a/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg b/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg index 4dd5e1506a..201fffc842 100644 --- a/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg +++ b/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg @@ -6,7 +6,7 @@ editor and edit_date), but includes general tests for confirming authority update propagation to bib records. */ -SELECT plan(8); +SELECT plan(9); INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name, passwd, first_given_name, expire_date, dob, suffix) @@ -52,6 +52,25 @@ SELECT is( 'Bib edit_date is updated' ); +-- Apply a change to the authority record that has no effect on the bib. + +UPDATE biblio.record_entry + SET editor = 1, edit_date = NOW() - '1 week'::INTERVAL + WHERE id = 1234512345; + +UPDATE authority.record_entry SET + editor = CURRVAL('actor.usr_id_seq'), -- test user created above + marc = $$ + nz a22 o 4500999999100LOCAL20160606150106.0 ||||||||||||||||||||||||||||||||||LOCALLOCALDoe, Jane Smith999999100authoritytest +$$ +WHERE id = 999999100; + +SELECT isnt( + (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345), + CURRENT_DATE, + 'Authority change with no effect does not update bib record' +); + -- Reset the bib data for easier testing UPDATE biblio.record_entry diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql index c22b73db99..b5bd37526c 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.authority-propage-edit-date.sql @@ -7,13 +7,20 @@ CREATE OR REPLACE FUNCTION authority.propagate_changes (aid BIGINT, bid BIGINT) RETURNS BIGINT AS $func$ DECLARE bib_rec biblio.record_entry%ROWTYPE; + new_marc TEXT; BEGIN SELECT INTO bib_rec * FROM biblio.record_entry WHERE id = bid; - bib_rec.marc := vandelay.merge_record_xml( + new_marc := vandelay.merge_record_xml( bib_rec.marc, authority.generate_overlay_template(aid)); + IF new_marc = bib_rec.marc THEN + -- Authority record change had no impact on this bib record. + -- Nothing left to do. + RETURN aid; + END IF; + PERFORM 1 FROM config.global_flag WHERE name = 'ingest.disable_authority_auto_update_bib_meta' AND enabled; @@ -26,7 +33,7 @@ BEGIN END IF; UPDATE biblio.record_entry SET - marc = bib_rec.marc, + marc = new_marc, editor = bib_rec.editor, edit_date = bib_rec.edit_date WHERE id = bid;