From: erickson Date: Thu, 29 Apr 2010 14:17:20 +0000 (+0000) Subject: after a record has been successfully imported via vandelay in the stream importer... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0689d10cf1ede10f859481ee9b17cb1c7c12716c;p=evergreen%2Fbjwebb.git after a record has been successfully imported via vandelay in the stream importer, remove the record from the bib queue to prevent bloat git-svn-id: svn://svn.open-ils.org/ILS/trunk@16343 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/support-scripts/marc_stream_importer.pl b/Open-ILS/src/support-scripts/marc_stream_importer.pl index 11246fab4..ad8d408e8 100755 --- a/Open-ILS/src/support-scripts/marc_stream_importer.pl +++ b/Open-ILS/src/support-scripts/marc_stream_importer.pl @@ -29,6 +29,7 @@ use Pod::Usage; use OpenSRF::Utils::Logger qw/$logger/; use OpenSRF::AppSession; +use OpenSRF::EX qw/:try/; use OpenILS::Utils::Cronscript; require 'oils_header.pl'; use vars qw/$apputils/; @@ -236,10 +237,13 @@ sub bib_queue_import { my $extra = {auto_overlay_exact => 1}; $extra->{merge_profile} = $merge_profile if $merge_profile; + my $req; + my @cleanup_recs; + if($import_by_queue) { + # import by queue - $apputils->simplereq( - 'open-ils.vandelay', + $req = $vl_ses->request( 'open-ils.vandelay.bib_queue.import', $authtoken, $queue_id, @@ -247,17 +251,40 @@ sub bib_queue_import { ); } else { - # import explicit record IDs - $apputils->simplereq( - 'open-ils.vandelay', + $req = $vl_ses->request( 'open-ils.vandelay.bib_record.list.import', $authtoken, $rec_ids, $extra ); } + + # collect the successfully imported vandelay records + while(my $resp = $req->recv) { + if($req->failed) { + $logger->error("Error importing MARC data: $resp"); + + } elsif(my $data = $resp->content) { + push(@cleanup_recs, $data->{imported}) unless $data->{err_event}; + } + } + + # clean up the successfully imported vandelay records to prevent queue bloat + foreach (@cleanup_recs) { + + try { + $apputils->simplereq( + 'open-ils.pcrud', + 'open-ils.pcrud.delete.vqbr', + $authtoken, $_); + + } catch Error with { + my $err = shift; + $logger->error("Error deleteing queued bib record $_: $err"); + }; + } } sub process_batch_data {