Bug 29078: Resolve division by zero in touch_all scripts
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 22 Sep 2021 14:06:07 +0000 (14:06 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 28 Sep 2021 13:12:45 +0000 (15:12 +0200)
Illegal division by zero at misc/maintenance/touch_all_biblios.pl line 102.

Trivial fix.
Funny that the percentage is not even shown without verbose flag ;)

Test plan:
Run misc/maintenance/touch_all_biblios.pl -where 'biblionumber<0'
You should now see:
Good: 0, Bad: 0 (of 0) in 0 seconds

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
misc/maintenance/touch_all_biblios.pl
misc/maintenance/touch_all_items.pl

index be349cf..2c725ae 100755 (executable)
@@ -101,7 +101,7 @@ close($fh);
 # Benchmarking
 my $endtime = time();
 my $time = $endtime-$startime;
-my $accuracy = ($goodcount / $totalcount) * 100; # this is a percentage
+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";
index 0879144..c253959 100755 (executable)
@@ -109,7 +109,7 @@ close($fh);
 # Benchmarking
 my $endtime = time();
 my $time = $endtime-$startime;
-my $accuracy = ($goodcount / $totalcount) * 100; # this is a percentage
+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";