Enrich the MARC records and track the enrichment
authorDan Scott <dscott@laurentian.ca>
Tue, 13 Jan 2015 14:09:08 +0000 (09:09 -0500)
committerDan Scott <dscott@laurentian.ca>
Tue, 13 Jan 2015 14:09:08 +0000 (09:09 -0500)
Still need to do error-handling so we can report problems encountered
with individual records and continue on in a cron job, but this gets
us a good chunk of the way there.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/update_marc_records_in_database.sql

index 4d3395d..448b234 100644 (file)
@@ -189,3 +189,16 @@ CREATE OR REPLACE FUNCTION conifer.marc_version() RETURNS TEXT AS $func$
 use MARC::Record;
 return $MARC::Record::VERSION;
 $func$ LANGUAGE PLPERLU;
+
+CREATE OR REPLACE FUNCTION conifer.enrich_next() RETURNS BIGINT AS $func$
+DECLARE
+    last_id BIGINT;
+    next_id BIGINT;
+BEGIN
+    SELECT id INTO last_id FROM conifer.conifer.enriched_bre LIMIT 1;
+    SELECT id INTO next_id FROM asset.opac_visible_copies WHERE id > last_id ORDER BY id LIMIT 1;
+    UPDATE biblio.record_entry SET marc = conifer.enrich_uris(next_id), edit_date = NOW() WHERE id = next_id;
+    UPDATE conifer.enriched_bre SET id = next_id;
+    RETURN next_id;
+END;
+$func$ LANGUAGE PLPGSQL;