JBAS-1437 Backstage export skips bibs with warnings
authorBill Erickson <berickxx@gmail.com>
Fri, 9 Dec 2016 16:00:43 +0000 (08:00 -0800)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
So far this only affects bibs with invalid leader lengths.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/authority-control/backstage/export-bibs.pl

index 3858a31..a82a0b0 100755 (executable)
@@ -198,6 +198,7 @@ sub export_marc {
 
     $sth->execute;
     my $count = 0;
+    my @skipped;
     while (my $bib = $sth->fetchrow_hashref) {
         $count++;
         next if $count_only;
@@ -216,9 +217,14 @@ sub export_marc {
         my $marc = $rec->[0]->[0];
         my $marcdoc = MARC::Record->new_from_xml($marc, 'UTF-8', 'USMARC');
 
-        print MARCFILE $marcdoc->as_usmarc;
+        if (my @warnings = $marcdoc->warnings) {
+            print "Skipping record $bib_id on warnings: @warnings\n";
+            push(@skipped, $bib_id);
+        } else {
+            print MARCFILE $marcdoc->as_usmarc;
+        }
 
-        print "$count records written...\n" if ($count % 1000) == 0;
+        print "$count records processed...\n" if ($count % 1000) == 0;
 
         next unless $export_date;
 
@@ -230,7 +236,11 @@ sub export_marc {
 
     close(MARCFILE) if $out_file;
 
-    print "$count total bib records\n";
+    my $skip_count = scalar(@skipped);
+    print "total bib count = $count\n";
+    print "skipped bib count = $skip_count\n";
+    print "export bib count = ".($count - $skip_count)."\n";
+    print "skipped bibs: @skipped\n";
 
     $sth->finish;
     $edate_sth->finish;