Add a stored procedure to reingest problematic URIs user/dbs/lp797304_lp797307
authorDan Scott <dan@coffeecode.net>
Wed, 15 Jun 2011 02:35:26 +0000 (22:35 -0400)
committerDan Scott <dan@coffeecode.net>
Wed, 15 Jun 2011 02:35:26 +0000 (22:35 -0400)
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 <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/upgrade/XXXX.biblio.extract_located_uris.sql

index 14100d0..434443d 100644 (file)
@@ -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();