[open-ils-commits] r16343 - trunk/Open-ILS/src/support-scripts (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Apr 29 10:17:22 EDT 2010
Author: erickson
Date: 2010-04-29 10:17:20 -0400 (Thu, 29 Apr 2010)
New Revision: 16343
Modified:
trunk/Open-ILS/src/support-scripts/marc_stream_importer.pl
Log:
after a record has been successfully imported via vandelay in the stream importer, remove the record from the bib queue to prevent bloat
Modified: trunk/Open-ILS/src/support-scripts/marc_stream_importer.pl
===================================================================
--- trunk/Open-ILS/src/support-scripts/marc_stream_importer.pl 2010-04-29 14:17:19 UTC (rev 16342)
+++ trunk/Open-ILS/src/support-scripts/marc_stream_importer.pl 2010-04-29 14:17:20 UTC (rev 16343)
@@ -29,6 +29,7 @@
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 @@
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 @@
);
} 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 {
More information about the open-ils-commits
mailing list