@@ -, +, @@ link_bibs_to_authorities.pl time link_bibs_to_authorities.pl -v -l --test ... and notice how long it takes to complete. time link_bibs_to_authorities.pl -v -l --test -g=700 ... and, again, notice how long it takes to complete. The 2nd run should run faster than the 1st one. --- C4/Biblio.pm | 4 ++++ misc/link_bibs_to_authorities.pl | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -482,6 +482,7 @@ sub LinkBibHeadingsToAuthorities { my $bib = shift; my $frameworkcode = shift; my $allowrelink = shift; + my $tagtolink = shift; my %results; if (!$bib) { carp 'LinkBibHeadingsToAuthorities called on undefined bib record'; @@ -493,6 +494,9 @@ sub LinkBibHeadingsToAuthorities { $allowrelink = 1 unless defined $allowrelink; my $num_headings_changed = 0; foreach my $field ( $bib->fields() ) { + if ( defined $tagtolink ) { + next unless $field->tag() == $tagtolink ; + } my $heading = C4::Heading->new_from_field( $field, $frameworkcode ); next unless defined $heading; --- a/misc/link_bibs_to_authorities.pl +++ a/misc/link_bibs_to_authorities.pl @@ -36,6 +36,7 @@ my $want_help = 0; my $auth_limit; my $bib_limit; my $commit = 100; +my $tagtolink; my $result = GetOptions( 'v|verbose' => \$verbose, @@ -44,6 +45,7 @@ my $result = GetOptions( 'a|auth-limit=s' => \$auth_limit, 'b|bib-limit=s' => \$bib_limit, 'c|commit=i' => \$commit, + 'g|tagtolink=i' => \$tagtolink, 'h|help' => \$want_help ); @@ -77,13 +79,13 @@ my %linked_headings; my %fuzzy_headings; my $dbh = C4::Context->dbh; $dbh->{AutoCommit} = 0; -process_bibs( $linker, $bib_limit, $auth_limit, $commit ); +process_bibs( $linker, $bib_limit, $auth_limit, $commit, $tagtolink ); $dbh->commit(); exit 0; sub process_bibs { - my ( $linker, $bib_limit, $auth_limit, $commit ) = @_; + my ( $linker, $bib_limit, $auth_limit, $commit, $tagtolink ) = @_; my $bib_where = ''; my $starttime = time(); if ($bib_limit) { @@ -95,7 +97,7 @@ sub process_bibs { $sth->execute(); while ( my ($biblionumber) = $sth->fetchrow_array() ) { $num_bibs_processed++; - process_bib( $linker, $biblionumber ); + process_bib( $linker, $biblionumber, $tagtolink ); if ( not $test_only and ( $num_bibs_processed % $commit ) == 0 ) { print_progress_and_commit($num_bibs_processed); @@ -187,6 +189,7 @@ _FUZZY_HEADER_ sub process_bib { my $linker = shift; my $biblionumber = shift; + my $tagtolink = shift; my $bib = GetMarcBiblio({ biblionumber => $biblionumber }); unless ( defined $bib ) { @@ -197,9 +200,10 @@ sub process_bib { } my $frameworkcode = GetFrameworkCode($biblionumber); + my $allowrelink = C4::Context->preference("CatalogModuleRelink") || ''; my ( $headings_changed, $results ) = - LinkBibHeadingsToAuthorities( $linker, $bib, $frameworkcode ); + LinkBibHeadingsToAuthorities( $linker, $bib, $frameworkcode, $allowrelink, $tagtolink ); foreach my $key ( keys %{ $results->{'unlinked'} } ) { $unlinked_headings{$key} += $results->{'unlinked'}->{$key}; } @@ -246,6 +250,7 @@ link_bibs_to_authorities.pl link_bibs_to_authorities.pl --commit=1000 link_bibs_to_authorities.pl --auth-limit=STRING link_bibs_to_authorities.pl --bib-limit=STRING + link_bibs_to_authorities.pl -g=700 =head1 DESCRIPTION @@ -281,6 +286,10 @@ Only process those bib records that match the user-specified WHERE clause. Commit the results to the database after every N records are processed. +=item B<-g=N> + +Only process those headings found in MARC field N. + =item B<--test> Only test the authority linking and report the results; do not change the bib --