Bugzilla – Attachment 121920 Details for
Bug 13706
Deduping authorities script (dedup_authorities.pl)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13706: Update some code
Bug-13706-Update-some-code.patch (text/plain), 6.33 KB, created by
Nick Clemens (kidclamp)
on 2021-06-14 18:20:33 UTC
(
hide
)
Description:
Bug 13706: Update some code
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-06-14 18:20:33 UTC
Size:
6.33 KB
patch
obsolete
>From 3cab9470725138bdfba4307e4ac10cc1287d906c Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 14 Jun 2021 18:16:39 +0000 >Subject: [PATCH] Bug 13706: Update some code > >This updates a few things: >- ZebraIndex module does not exist >- merge calls ModBiblio, so the records are reindexed during merge >- DelAuthority used to remove records - no reindex needed after > >Remaining issues: >- SimpleSearch doesn't work - only 'he' has an entry in ccl.properties >- abbreviations for indexes (he-main etc) do not exist anywhere >- There should be an option to use 'Match' and automatically generate the search term from the auth record (search_form in Headings.pm) based on the authtype >- The default options are unimarc centric >- this should be in module and testable >--- > misc/migration_tools/dedup_authorities.pl | 72 +++++++++++++------------------ > 1 file changed, 29 insertions(+), 43 deletions(-) > >diff --git a/misc/migration_tools/dedup_authorities.pl b/misc/migration_tools/dedup_authorities.pl >index e30c49399d..406e55f286 100755 >--- a/misc/migration_tools/dedup_authorities.pl >+++ b/misc/migration_tools/dedup_authorities.pl >@@ -6,7 +6,6 @@ use C4::Biblio; > use C4::Search; > use C4::Charset; > use C4::Debug; >-use C4::ZebraIndex; > > use Getopt::Long; > use YAML; >@@ -24,20 +23,21 @@ Use this script to remove duplicate authorities. > > my @matchstrings; > my $choosemethod = "u"; # by default, choose to keep the most used authority >-my ($verbose, $all, $help, $wherestring, $test); >+my ($all, $help, $wherestring, $test); >+my $verbose = 0; > > # default is to check all these subfields for 'auth_tag_to_report' > my $check = 'TAGabcdefghitxyz'; > > my $result = GetOptions ( >- "match=s" => \@matchstrings >- , "verbose+" => \$verbose >- , "all|a" => \$all >- , "test|t" => \$test >- , "help|h" => \$help >- , "where=s" => \$wherestring >- , "choose-method=s" => \$choosemethod >- , "check=s" => \$check >+ "match=s" => \@matchstrings, >+ "verbose+" => \$verbose, >+ "all|a" => \$all, >+ "test|t" => \$test, >+ "help|h" => \$help, >+ "where=s" => \$wherestring, >+ "choose-method=s" => \$choosemethod, >+ "check=s" => \$check > ); > > if ( $help || ! (@ARGV || $all)) { >@@ -47,19 +47,17 @@ if ( $help || ! (@ARGV || $all)) { > > my @choose_subs; > foreach (split //, $choosemethod) { >- given($_) { >- when ('d') { >- push @choose_subs, \&_get_date; >- } >- when ('p') { >- push @choose_subs, \&_has_ppn; >- } >- when ('u') { >- push @choose_subs, \&_get_usage; >- } >- default { >- warn "Choose method '$_' is not supported"; >- } >+ if ($_ eq 'd') { >+ push @choose_subs, \&_get_date; >+ } >+ elsif( $_ eq 'p') { >+ push @choose_subs, \&_has_ppn; >+ } >+ elsif( $_ eq 'u') { >+ push @choose_subs, \&_get_usage; >+ } >+ else { >+ warn "Choose method '$_' is not supported"; > } > } > >@@ -153,10 +151,10 @@ for my $authtypecode (@authtypecodes) { > ($verbose >= 2) and logger("Building query..."); > my $query = _build_query( $authrecord, $attempt ); > ($verbose >= 2) and logger("Building query done."); >- ($verbose >= 2) and logger ($query); >+ ($verbose >= 2) and logger ("$query"); > # This prevent too general queries to be executed > # TODO: This should allow more than these 3 indexes >- next unless $query =~ /(ppn|he|he-main|ident)(,\S*)*(=|:)/; >+# next unless $query =~ /(ppn|he|heading-main|ident)(,\S*)*(=|:)/; > > ($verbose >= 2) and logger("Searching..."); > my ($error, $results) = SimpleSearch($query, undef, undef, ["authorityserver"]); >@@ -191,6 +189,8 @@ for my $authtypecode (@authtypecodes) { > $biblios{$biblio} = 1; > } > $authorities{$localauthid} = 2; >+ logger("Deleting $localauthid"); >+ DelAuthority({ authid => $localauthid, skip_merge => 1 }); > } > } > ($verbose >= 2) and logger("Merge done."); >@@ -214,31 +214,17 @@ for my $authtypecode (@authtypecodes) { > my @biblios_to_update = grep {defined $biblios{$_} and $biblios{$_} == 1} > keys %biblios; > if( @biblios_to_update > 0 ) { >- logger("Updating biblios index (" . scalar(@biblios_to_update) . " biblios to update)"); >- C4::ZebraIndex::IndexRecord("biblio", \@biblios_to_update, >- { as_xml => 1, record_format => "marcxml" }); >+ logger("Updated " . scalar(@biblios_to_update) . " biblios"); > } else { > logger("No biblios to update"); > } > >-# Update authorities >-my @authorities_to_update = grep{defined $authorities{$_} and $authorities{$_} == 1} >- keys %authorities; >-if( @authorities_to_update > 0 ) { >- logger("Updating authorities index (" . scalar(@authorities_to_update) . " authorities to update)"); >- C4::ZebraIndex::IndexRecord("authority", \@authorities_to_update, >- { as_xml => 1, record_format => "marcxml" }); >-} else { >- logger("No autorities to update"); >-} > > # Delete authorities > my @authorities_to_delete = grep{defined $authorities{$_} and $authorities{$_} == 2} > keys %authorities; > if( @authorities_to_delete > 0 ) { >- logger("Deleting authorities from index (" . scalar(@authorities_to_delete) . " authorities to delete)"); >- C4::ZebraIndex::DeleteRecordIndex("authority", \@authorities_to_delete, >- { as_xml => 1, record_format => "marcxml" }); >+ logger("Deleted " . scalar(@authorities_to_delete) . " authorities"); > } else { > logger("No authorities to delete"); > } >@@ -296,13 +282,13 @@ sub prepare_strings{ > } > } > else { >- if ($attempt->{subfields}){ >+ if (scalar @{$attempt->{subfields}} ){ > for my $subfield (@{$attempt->{subfields}}){ > push @stringstosearch, trim(map { NormalizeString($_, undef, 1) } $field->subfield($subfield)); > } > } > else { >- push @stringstosearch, trim(map { NormalizeString($_, undef, 1) } $field->as_string()); >+ push @stringstosearch, trim(map { NormalizeString($_, undef, 1) } ($field->as_string()) ); > } > > } >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13706
:
35885
|
40068
|
40069
|
121920
|
122049
|
124659
|
127263
|
157935
|
157965
|
163030
|
163031