From eff594200dd9ef5aea5792ede65d46fa55dae446 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 12 Oct 2020 00:21:03 +0000 Subject: [PATCH] Bug 26657: Differentiate between unlinked and not linked This patch differentiates between unlinked (a linkage is removed) and not linked (there is no linkage) in the output of LinkBibHeadingsToAuthorities. Test plan: 0. Use koha-testing-docker 1. koha-shell -c "./misc/link_bibs_to_authorities.pl -l --test" kohadev 2. Note 436 bibs checked, 1315 headings linked, 678 headings not linked (Previously, the "not linked" headings would have been under the "unlinked" category.) --- C4/Biblio.pm | 2 +- misc/link_bibs_to_authorities.pl | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 6b7e78e05b..67ef54389e 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -608,7 +608,7 @@ sub LinkBibHeadingsToAuthorities { } } else { - $results{'unlinked'}->{ $heading->display_form() }++; + $results{'nonlinked'}->{ $heading->display_form() }++; } } diff --git a/misc/link_bibs_to_authorities.pl b/misc/link_bibs_to_authorities.pl index 9044292185..d66d5ca455 100755 --- a/misc/link_bibs_to_authorities.pl +++ b/misc/link_bibs_to_authorities.pl @@ -75,6 +75,7 @@ my $num_bad_bibs = 0; my %unlinked_headings; my %linked_headings; my %fuzzy_headings; +my %nonlinked_headings; my $dbh = C4::Context->dbh; $dbh->{AutoCommit} = 0; process_bibs( $linker, $bib_limit, $auth_limit, $commit ); @@ -108,9 +109,11 @@ sub process_bibs { my $headings_linked = 0; my $headings_unlinked = 0; + my $headings_nonlinked = 0; my $headings_fuzzy = 0; for ( values %linked_headings ) { $headings_linked += $_; } for ( values %unlinked_headings ) { $headings_unlinked += $_; } + for ( values %nonlinked_headings ) { $headings_nonlinked += $_; } for ( values %fuzzy_headings ) { $headings_fuzzy += $_; } my $endtime = time(); @@ -132,6 +135,7 @@ Number of bibs with errors: $num_bad_bibs Number of headings linked: $headings_linked Number of headings unlinked: $headings_unlinked Number of headings fuzzily linked: $headings_fuzzy +Number of headings not linked: $headings_nonlinked _SUMMARY_ $summary .= "\n**** Ran in test mode only ****\n" if $test_only; print $summary; @@ -180,6 +184,22 @@ _FUZZY_HEADER_ foreach my $key (@keys) { print "$key:\t" . $fuzzy_headings{$key} . " occurrences\n"; } + + print <<_NONLINKED_HEADER_; + +Not linked headings (from most frequent to least): +------------------------------------------------------- + +_NONLINKED_HEADER_ + + @keys = sort { + $nonlinked_headings{$b} <=> $nonlinked_headings{$a} + or "\L$a" cmp "\L$b" + } keys %nonlinked_headings; + foreach my $key (@keys) { + print "$key:\t" . $nonlinked_headings{$key} . " occurrences\n"; + } + print $summary; } } @@ -203,6 +223,9 @@ sub process_bib { foreach my $key ( keys %{ $results->{'unlinked'} } ) { $unlinked_headings{$key} += $results->{'unlinked'}->{$key}; } + foreach my $key ( keys %{ $results->{'nonlinked'} } ) { + $nonlinked_headings{$key} += $results->{'nonlinked'}->{$key}; + } foreach my $key ( keys %{ $results->{'linked'} } ) { $linked_headings{$key} += $results->{'linked'}->{$key}; } -- 2.11.0