From b6151ac81e9b8e56f70ea5ff449da6e402967131 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 24 Sep 2021 16:14:44 -0400 Subject: [PATCH] LP#1729620: (follow-up) do not suggest timestamp manipulation The suggestion in the upgrade script and the release notes to consider adding triggers to update biblio.record_entry.timestamp upon updates of linked call numbers or items is not a good one: [1] implementing it means that any workflows that require knowing when a bib itself has changed become untrustworthy [2] it would cause tremendous bloating of auditor.biblio_record_entry_history, as every single change to an item -- including ones caused by circulation activity -- would result in a new entry. [3] item changes due to circulation activity aren't necessarily going to want to trigger record updates by the harvester Wanting the update timestamp for OAI harvest to reflect changes to items is a perfectly valid use case, but this is not the way. Signed-off-by: Galen Charlton Signed-off-by: Mike Rylander Signed-off-by: Jane Sandberg --- .../src/sql/Pg/upgrade/XXXX.schema.oai_views.sql | 48 -------------------- .../OAI2/new_oai_opensrf_service.adoc | 53 ---------------------- 2 files changed, 101 deletions(-) diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.oai_views.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.oai_views.sql index ef89efc925..58b766ad67 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.oai_views.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.oai_views.sql @@ -27,53 +27,5 @@ CREATE VIEW oai.authority AS ORDER BY are.id; - --- OPTIONAL PORTION - -\qecho If an edit date changes in the asset.call_number or asset.copy and you want this to persist to an OAI2 datestamp, -\qecho then add these stored procedures and triggers: -\qecho -\qecho 'CREATE OR REPLACE FUNCTION oai.datestamp(rid BIGINT)' -\qecho ' RETURNS VOID AS $$' -\qecho 'BEGIN' -\qecho ' UPDATE biblio.record_entry AS bre' -\qecho ' SET edit_date = now()' -\qecho ' WHERE bre.id = rid;' -\qecho 'END' -\qecho '$$ LANGUAGE plpgsql;' -\qecho -\qecho 'CREATE OR REPLACE FUNCTION oai.call_number_datestamp()' -\qecho ' RETURNS TRIGGER AS $$' -\qecho 'BEGIN' -\qecho ' IF TG_OP = ''DELETE''' -\qecho ' THEN' -\qecho ' PERFORM oai.datestamp(OLD.record);' -\qecho ' RETURN OLD;' -\qecho ' END IF;' -\qecho -\qecho ' PERFORM oai.datestamp(NEW.record);' -\qecho ' RETURN NEW;' -\qecho -\qecho 'END' -\qecho '$$ LANGUAGE plpgsql;' -\qecho -\qecho 'CREATE OR REPLACE FUNCTION oai.copy_datestamp()' -\qecho ' RETURNS TRIGGER AS $$' -\qecho 'BEGIN' -\qecho ' IF TG_OP = ''DELETE''' -\qecho ' THEN' -\qecho ' PERFORM oai.datestamp((SELECT acn.record FROM asset.call_number as acn WHERE acn.id = OLD.call_number));' -\qecho ' RETURN OLD;' -\qecho ' END IF;' -\qecho -\qecho ' PERFORM oai.datestamp((SELECT acn.record FROM asset.call_number as acn WHERE acn.id = NEW.call_number));' -\qecho ' RETURN NEW;' -\qecho -\qecho 'END' -\qecho '$$ LANGUAGE plpgsql;' -\qecho -\qecho 'CREATE TRIGGER call_number_datestamp AFTER INSERT OR UPDATE OR DELETE ON asset.call_number FOR EACH ROW EXECUTE PROCEDURE oai.call_number_datestamp();' -\qecho 'CREATE TRIGGER copy_datestamp AFTER INSERT OR UPDATE OR DELETE ON asset.copy FOR EACH ROW EXECUTE PROCEDURE oai.copy_datestamp();' - COMMIT; diff --git a/docs/RELEASE_NOTES_NEXT/OAI2/new_oai_opensrf_service.adoc b/docs/RELEASE_NOTES_NEXT/OAI2/new_oai_opensrf_service.adoc index 22a7b91c7e..df40881f45 100644 --- a/docs/RELEASE_NOTES_NEXT/OAI2/new_oai_opensrf_service.adoc +++ b/docs/RELEASE_NOTES_NEXT/OAI2/new_oai_opensrf_service.adoc @@ -95,56 +95,3 @@ section and restart Apache: # ---- -Optional: Setting the datestamp -+++++++++++++++++++++++++++++++ - -The edit date of the bibliographic and authority record is used as -datestamp. If you want the date for editorial updates of bibliographic -assets (i.e. copies, call numbers) reflected in the datestamp, then add the -triggers shown below. - -```sql - -CREATE OR REPLACE FUNCTION oai.datestamp(rid BIGINT) - RETURNS VOID AS $$ -BEGIN - UPDATE biblio.record_entry AS bre - SET edit_date = now() - WHERE bre.id = rid; -END -$$ LANGUAGE plpgsql; - -CREATE OR REPLACE FUNCTION oai.call_number_datestamp() - RETURNS TRIGGER AS $$ -BEGIN - IF TG_OP = 'DELETE' - THEN - PERFORM oai.datestamp(OLD.record); - RETURN OLD; - END IF; - - PERFORM oai.datestamp(NEW.record); - RETURN NEW; - -END -$$ LANGUAGE plpgsql; - -CREATE OR REPLACE FUNCTION oai.copy_datestamp() - RETURNS TRIGGER AS $$ -BEGIN - IF TG_OP = 'DELETE' - THEN - PERFORM oai.datestamp((SELECT acn.record FROM asset.call_number as acn WHERE acn.id = OLD.call_number)); - RETURN OLD; - END IF; - - PERFORM oai.datestamp((SELECT acn.record FROM asset.call_number as acn WHERE acn.id = NEW.call_number)); - RETURN NEW; - -END -$$ LANGUAGE plpgsql; - -CREATE TRIGGER call_number_datestamp AFTER INSERT OR UPDATE OR DELETE ON asset.call_number FOR EACH ROW EXECUTE PROCEDURE oai.call_number_datestamp(); -CREATE TRIGGER copy_datestamp AFTER INSERT OR UPDATE OR DELETE ON asset.copy FOR EACH ROW EXECUTE PROCEDURE oai.copy_datestamp(); -``` - -- 2.11.0