3 # Copyright (C) 2011 ByWater Solutions
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 # possible modules to use
24 use Getopt::Long qw( GetOptions );
28 use C4::Biblio qw( ModBiblio );
30 use Pod::Usage qw( pod2usage );
34 pod2usage( -verbose => 2 );
39 my $dbh = C4::Context->dbh;
41 # Benchmarking variables
42 my $startime = time();
54 'o|output:s' => \$outfile,
56 'where:s' => \$whereclause,
63 $whereclause = "WHERE $whereclause";
66 # output log or STDOUT
68 if (defined $outfile) {
69 open ($fh, '>', $outfile) || die ("Cannot open output file");
71 open($fh, '>&', \*STDOUT) || die ("Couldn't duplicate STDOUT: $!");
74 my $sth1 = $dbh->prepare("SELECT biblionumber, frameworkcode FROM biblio $whereclause");
77 # fetch info from the search
78 while (my ($biblionumber, $frameworkcode) = $sth1->fetchrow_array){
79 my $biblio = Koha::Biblios->find($biblionumber);
80 my $record = $biblio->metadata->record;
82 my $modok = ModBiblio($record, $biblionumber, $frameworkcode);
86 print $fh "Touched biblio $biblionumber\n" if (defined $verbose);
89 print $fh "ERROR WITH BIBLIO $biblionumber !!!!\n";
99 my $time = $endtime-$startime;
100 my $accuracy = $totalcount ? ($goodcount / $totalcount) * 100 : 0; # this is a percentage
102 $averagetime = $time / $totalcount if $totalcount;
103 print "Good: $goodcount, Bad: $badcount (of $totalcount) in $time seconds\n";
104 printf "Accuracy: %.2f%%\nAverage time per record: %.6f seconds\n", $accuracy, $averagetime if (defined $verbose);
113 touch_all_biblios.pl -v
114 touch_all_biblios.pl --where=STRING
118 When changes are made to ModBiblio (or the routines that are called by those),
119 it is sometimes necessary to run ModBiblio on all or some records in the catalog
120 when upgrading. This script does this.
130 Provide verbose log information.
134 Limits the search with a user-specified WHERE clause.