From 7be2a32620587af27de4316e42a308e913e9314c Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 14 Jun 2011 22:35:26 -0400 Subject: [PATCH] Add a stored procedure to reingest problematic URIs Assuming that href = label in asset.uri is a red enough flag for the problem in LP 797307 where the perfectly good label was being thrown away, reingest the unique set of records connected with such asset.uri rows. Signed-off-by: Dan Scott --- .../upgrade/XXXX.biblio.extract_located_uris.sql | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.biblio.extract_located_uris.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.biblio.extract_located_uris.sql index 14100d07e8..434443df05 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.biblio.extract_located_uris.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.biblio.extract_located_uris.sql @@ -109,4 +109,29 @@ BEGIN END; $func$ LANGUAGE PLPGSQL; +CREATE OR REPLACE FUNCTION biblio.reingest_uris() RETURNS VOID AS $func$ +DECLARE + rec_id BIGINT; +BEGIN + -- Get the distinct set of record IDs that need to be reingested + -- (assuming that href = label is a reasonable red flag) + FOR rec_id IN SELECT rec_uris.id FROM ( + SELECT acn.record AS id + FROM asset.call_number acn + INNER JOIN asset.uri_call_number_map auricnm ON auricnm.call_number = acn.id + INNER JOIN asset.uri auri ON auri.id = auricnm.uri + WHERE auri.href = auri.label + GROUP BY acn.record + ORDER BY acn.record + ) AS rec_uris + LOOP + -- Reingest the offending records + PERFORM biblio.extract_located_uris(rec_id, bre.marc, 1) + FROM biblio.record_entry bre + WHERE bre.id = rec_id; + END LOOP; +END; +$func$ LANGUAGE PLPGSQL; +-- Kick off the reingest; this may take a while +SELECT biblio.reingest_uris(); -- 2.11.0