Bugzilla – Attachment 175394 Details for
Bug 38133
Create a touch_all_authorities.pl script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
touch_all_authorities script
touch_all_authorities.pl (text/plain), 3.13 KB, created by
Bernard
on 2024-12-12 11:12:17 UTC
(
hide
)
Description:
touch_all_authorities script
Filename:
MIME Type:
Creator:
Bernard
Created:
2024-12-12 11:12:17 UTC
Size:
3.13 KB
patch
obsolete
>#!/usr/bin/perl ># ># Copyright (C) 2011 ByWater Solutions ># ># This file is part of Koha. ># ># Koha is free software; you can redistribute it and/or modify it ># under the terms of the GNU General Public License as published by ># the Free Software Foundation; either version 3 of the License, or ># (at your option) any later version. ># ># Koha is distributed in the hope that it will be useful, but ># WITHOUT ANY WARRANTY; without even the implied warranty of ># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ># GNU General Public License for more details. ># ># You should have received a copy of the GNU General Public License ># along with Koha; if not, see <http://www.gnu.org/licenses>. > >use strict; >use warnings; > ># possible modules to use >use Getopt::Long qw( GetOptions ); > >use Koha::Script; >use C4::Context; >use C4::AuthoritiesMarc qw( ModAuthority ); >use Koha::Authorities; >use Pod::Usage qw( pod2usage ); >use Data::Dumper; > > >sub usage { > pod2usage( -verbose => 2 ); > exit; >} > ># Database handle >my $dbh = C4::Context->dbh; > ># Benchmarking variables >my $startime = time(); >my $goodcount = 0; >my $badcount = 0; >my $totalcount = 0; > ># Options >my $verbose; >my $whereclause = ''; >my $help; >my $outfile; > >GetOptions( > 'o|output:s' => \$outfile, > 'v' => \$verbose, > 'where:s' => \$whereclause, > 'help|h' => \$help, >); > >usage() if $help; > >if ($whereclause) { > $whereclause = "WHERE $whereclause"; >} > ># output log or STDOUT >my $fh; >if (defined $outfile) { > open ($fh, '>', $outfile) || die ("Cannot open output file"); >} else { > open($fh, '>&', \*STDOUT) || die ("Couldn't duplicate STDOUT: $!"); >} > >my $sth1 = $dbh->prepare("SELECT authid FROM auth_header $whereclause"); >$sth1->execute(); > ># fetch info from the search >while (my ($authid) = $sth1->fetchrow_array){ > my $authority = Koha::Authorities->find($authid); > my $authtypecode = $authority->authtypecode; > my $record = $authority->record; > > my $modok = ModAuthority( $authid, $record, $authtypecode ); > > if ($modok) { > $goodcount++; > print $fh "Touched authority $authid\n" if (defined $verbose); > } else { > $badcount++; > print $fh "ERROR WITH AUTHORITY $authid !!!!\n"; > } > > $totalcount++; > >} >close($fh); > ># Benchmarking >my $endtime = time(); >my $time = $endtime-$startime; >my $accuracy = $totalcount ? ($goodcount / $totalcount) * 100 : 0; # this is a percentage >my $averagetime = 0; >$averagetime = $time / $totalcount if $totalcount; >print "Good: $goodcount, Bad: $badcount (of $totalcount) in $time seconds\n"; >printf "Accuracy: %.2f%%\nAverage time per record: %.6f seconds\n", $accuracy, $averagetime if (defined $verbose); > >=head1 NAME > >touch_all_authorities.pl > >=head1 SYNOPSIS > > touch_all_authorities.pl > touch_all_authorities.pl -v > touch_all_authorities.pl --where=STRING > >=head1 DESCRIPTION > >When bibliographic records are linked to authorities but manual changes are also made to the entries, it is sometimes desired to set these linked records back to the authorised values. This script does this. > >=over 8 > >=item B<--help> > >Prints this help > >=item B<-v> > >Provide verbose log information. > >=item B<--where> > >Limits the search with a user-specified WHERE clause. > >=back > >=cut >
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 38133
: 175394