From: Bill Erickson Date: Wed, 7 Dec 2016 16:04:19 +0000 (-0500) Subject: JBAS-1437 Backstage importer process bibs first X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=476665999727da03bed67ec4acc6ff280c7944da;p=working%2FEvergreen.git JBAS-1437 Backstage importer process bibs first When processing a ZIP file, process bib files before authority files. On large data sets, processing bibs first allows staff to resume normal bib editing operations earlier. Signed-off-by: Bill Erickson --- diff --git a/KCLS/authority-control/backstage/process-backstage-files.pl b/KCLS/authority-control/backstage/process-backstage-files.pl index c034846b2d..e402b2c81e 100755 --- a/KCLS/authority-control/backstage/process-backstage-files.pl +++ b/KCLS/authority-control/backstage/process-backstage-files.pl @@ -26,7 +26,7 @@ my $marc_file; my $zip_file; my $export_date; my $working_dir = '.', -my $bib_collision_file; +my $bib_collision_file = 'bib-collisions.mrc'; # in --working-dir my $verbose; my $db_user = $ENV{PGUSER} || 'evergreen'; my $db_name = $ENV{PGDATABASE} || 'evergreen'; @@ -158,8 +158,10 @@ sub process_zip_file { announce('ERR', "Failed to read $zip_file", 1) unless $zip->read($zip_file) == AZ_OK; - # Avoid processing XLS and HTM files. - # All of the MARC files end in .UTF8. + my %marc_files = (bib => [], auth => []); + + # Start by locating the MARC files in the ZIP file + # All of the MARC files end in .UTF8 or MRC. for my $member ($zip->membersMatching('.*(\.UTF8|\.MRC)')) { my $basename = basename($member->fileName()); @@ -171,13 +173,18 @@ sub process_zip_file { announce('ERR', "Unable to extract to file: $local_file", 1) unless $member->extractToFileNamed($local_file) == AZ_OK; - process_marc_file($local_file); + my $key = ($basename =~ /BIB/) ? 'bib' : 'auth'; + push(@{$marc_files{$key}}, $local_file); } + + # Then process bib files first, followed by authority files. + process_marc_file($_) for (@{$marc_files{bib}}, @{$marc_files{auth}}) } sub process_marc_file { my $local_file = shift; my $basename = basename($local_file); + announce('INFO', "Processing file $basename"); my $marc_batch = MARC::File::USMARC->in($local_file, 'UTF8') or announce('ERR', "Unable to read $local_file as MARC", 1); @@ -406,7 +413,8 @@ sub find_replaced_auths { my $matches = $match_auth_sth->fetchall_arrayref; my @ids = map {$_->[0]} @$matches; - announce('INFO', "Auth 010z=$subfield matched records: @ids") if @ids; + announce('INFO', "Auth 010z=$subfield matched records: @ids") + if $verbose && @ids; return @ids; } @@ -426,8 +434,8 @@ sub find_matching_auths { $match_auth_001_sth->execute($subfield); my $matches = $match_auth_001_sth->fetchall_arrayref; my @ids = map {$_->[0]} @$matches; - announce('INFO', - "Auth 001=$subfield matched records: @ids") if @ids; + announce('INFO', "Auth 001=$subfield matched records: @ids") + if $verbose && @ids; return @ids; } } @@ -446,7 +454,8 @@ sub find_matching_auths { my $matches = $match_auth_sth->fetchall_arrayref; my @ids = map {$_->[0]} @$matches; - announce('INFO', "Auth ${tag}a=$subfield matched records: @ids") if @ids; + announce('INFO', "Auth ${tag}a=$subfield matched records: @ids") + if $verbose && @ids; return @ids; }