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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 # find Koha's Perl modules
24 # test carefully before changing this
26 eval { require "$FindBin::Bin/../kohalib.pl" };
29 # possible modules to use
37 pod2usage( -verbose => 2 );
42 my $dbh = C4::Context->dbh;
44 # Benchmarking variables
45 my $startime = time();
57 'o|output:s' => \$outfile,
59 'where:s' => \$whereclause,
66 $whereclause = "WHERE $whereclause";
69 # output log or STDOUT
70 if (defined $outfile) {
71 open (OUT, ">$outfile") || die ("Cannot open output file");
73 open(OUT, ">&STDOUT") || die ("Couldn't duplicate STDOUT: $!");
76 my $sth_fetch = $dbh->prepare("SELECT biblionumber, itemnumber, itemcallnumber FROM items $whereclause");
77 $sth_fetch->execute();
79 # fetch info from the search
80 while (my ($biblionumber, $itemnumber, $itemcallnumber) = $sth_fetch->fetchrow_array){
82 my $modok = ModItem({itemcallnumber => $itemcallnumber}, $biblionumber, $itemnumber);
86 print OUT "Touched item $itemnumber\n" if (defined $verbose);
89 print OUT "ERROR WITH ITEM $itemnumber !!!!\n";
98 my $time = $endtime-$startime;
99 my $accuracy = ($goodcount / $totalcount) * 100; # this is a percentage
101 unless ($time == 0) {$averagetime = $totalcount / $time;};
102 print "Good: $goodcount, Bad: $badcount (of $totalcount) in $time seconds\n";
103 printf "Accuracy: %.2f%%\nAverage time per record: %.6f seconds\n", $accuracy, $averagetime if (defined $verbose);
112 touch_all_items.pl -v
113 touch_all_items.pl --where=STRING
117 When changes are made to ModItem (or the routines that are called by it), it is
118 sometimes necessary to run ModItem on all or some records in the catalog when
119 upgrading. This script does that.
129 Provide verbose log information.
133 Limits the search with a user-specified WHERE clause.