Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
# Small script that checks that each biblio in the DB is properly indexed |
3 |
|
4 |
use strict; |
5 |
|
6 |
use warnings; |
7 |
|
8 |
BEGIN { |
9 |
|
10 |
# find Koha's Perl modules |
11 |
# test carefully before changing this |
12 |
use FindBin; |
13 |
eval { require "$FindBin::Bin/kohalib.pl" }; |
14 |
} |
15 |
|
16 |
# Koha modules used |
17 |
use MARC::Record; |
18 |
use C4::Context; |
19 |
use C4::Search; |
20 |
use Time::HiRes qw(gettimeofday); |
21 |
|
22 |
use Getopt::Long; |
23 |
my ( $input_marc_file, $number ) = ( '', 0 ); |
24 |
my ( $version, $confirm, $zebraqueue, $silent ); |
25 |
GetOptions( |
26 |
'c' => \$confirm, |
27 |
'h' => \$version, |
28 |
'z' => \$zebraqueue, |
29 |
's' => \$silent |
30 |
); |
31 |
|
32 |
if ( $version || ( !$confirm ) ) { |
33 |
print <<EOF |
34 |
This script takes all biblios and check they are indexed in zebra using biblionumber search. |
35 |
|
36 |
parameters: |
37 |
\th this help screen |
38 |
\tc confirm (without this parameter, you get the help screen |
39 |
\tz insert a signal in zebraqueue to force indexing of non indexed biblios |
40 |
\ts silent throw no warnings except for non indexed records. Otherwise throw a warn every 1000 biblios to show progress |
41 |
|
42 |
Syntax: |
43 |
\t./batchCheckNonIndexedBiblios.pl -h (or without arguments => shows this screen) |
44 |
\t./batchCheckNonIndexedBiblios.pl -c (c like confirm => check all records (may be long) |
45 |
\t-t => test only, change nothing in DB |
46 |
EOF |
47 |
; |
48 |
exit; |
49 |
} |
50 |
|
51 |
my $dbh = C4::Context->dbh; |
52 |
my $i = 0; |
53 |
my $starttime = time(); |
54 |
|
55 |
$| = 1; # flushes output |
56 |
$starttime = gettimeofday; |
57 |
|
58 |
my $sth = $dbh->prepare("SELECT biblionumber FROM biblio"); |
59 |
my $sth_insert = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,operation,server,done) VALUES (?,'specialUpdate','biblioserver',0)"); |
60 |
$sth->execute; |
61 |
my ($nbhits); |
62 |
while ( my ($biblionumber) = $sth->fetchrow ) { |
63 |
(undef,undef,$nbhits) = SimpleSearch("Local-number=$biblionumber"); |
64 |
print "biblionumber $biblionumber not indexed\n" unless $nbhits; |
65 |
$sth_insert->execute($biblionumber) if $zebraqueue and !$nbhits; |
66 |
$i++; |
67 |
print "$i done\n" unless $i % 1000; |
68 |
} |
69 |
|