Lines 2491-2511
sub CountItemsIssued {
Link Here
|
2491 |
|
2491 |
|
2492 |
ModZebra( $biblionumber, $op, $server, $record ); |
2492 |
ModZebra( $biblionumber, $op, $server, $record ); |
2493 |
|
2493 |
|
2494 |
$biblionumber is the biblionumber we want to index |
2494 |
$biblionumbers are an arrayref of the biblionumbers we want to index, if single passed we convert to arrayref |
2495 |
|
2495 |
|
2496 |
$op is specialUpdate or recordDelete, and is used to know what we want to do |
2496 |
$op is specialUpdate or recordDelete, and is used to know what we want to do |
2497 |
|
2497 |
|
2498 |
$server is the server that we want to update |
2498 |
$server is the server that we want to update |
2499 |
|
2499 |
|
2500 |
$record is the update MARC record if it's available. If it's not supplied |
2500 |
$records are an arrayref of the updated MARC records if they are available. If they are not supplied |
2501 |
and is needed, it'll be loaded from the database. |
2501 |
and are needed, they will be loaded from the database using $biblionumbers param. If a single record passed we convert to array ref |
2502 |
|
2502 |
|
2503 |
=cut |
2503 |
=cut |
2504 |
|
2504 |
|
2505 |
sub ModZebra { |
2505 |
sub ModZebra { |
2506 |
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs |
2506 |
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs |
2507 |
my ( $biblionumber, $op, $server, $record ) = @_; |
2507 |
my ( $biblionumbers, $op, $server, $records ) = @_; |
2508 |
$debug && warn "ModZebra: update requested for: $biblionumber $op $server\n"; |
2508 |
$biblionumbers = [$biblionumbers] if ref $biblionumbers ne 'ARRAY' && defined $biblionumbers; |
|
|
2509 |
$records = [$records] if ref $biblionumbers ne 'ARRAY' && defined $records; |
2510 |
$debug && warn "ModZebra: updates requested for: @$biblionumbers $op $server\n"; |
2509 |
if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { |
2511 |
if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { |
2510 |
|
2512 |
|
2511 |
# TODO abstract to a standard API that'll work for whatever |
2513 |
# TODO abstract to a standard API that'll work for whatever |
Lines 2518-2533
sub ModZebra {
Link Here
|
2518 |
} |
2520 |
} |
2519 |
); |
2521 |
); |
2520 |
if ( $op eq 'specialUpdate' ) { |
2522 |
if ( $op eq 'specialUpdate' ) { |
2521 |
unless ($record) { |
2523 |
unless ($records) { |
2522 |
$record = GetMarcBiblio({ |
2524 |
foreach my $biblionumber ( @$biblionumbers ){ |
2523 |
biblionumber => $biblionumber, |
2525 |
my $record = GetMarcBiblio({ |
2524 |
embed_items => 1 }); |
2526 |
biblionumber => $biblionumber, |
|
|
2527 |
embed_items => 1 }); |
2528 |
push @$records, $record; |
2529 |
} |
2525 |
} |
2530 |
} |
2526 |
my $records = [$record]; |
2531 |
$indexer->update_index_background( $biblionumbers, $records ); |
2527 |
$indexer->update_index_background( [$biblionumber], [$record] ); |
|
|
2528 |
} |
2532 |
} |
2529 |
elsif ( $op eq 'recordDelete' ) { |
2533 |
elsif ( $op eq 'recordDelete' ) { |
2530 |
$indexer->delete_index_background( [$biblionumber] ); |
2534 |
$indexer->delete_index_background( $biblionumbers ); |
2531 |
} |
2535 |
} |
2532 |
else { |
2536 |
else { |
2533 |
croak "ModZebra called with unknown operation: $op"; |
2537 |
croak "ModZebra called with unknown operation: $op"; |
Lines 2540-2558
sub ModZebra {
Link Here
|
2540 |
# at the same time |
2544 |
# at the same time |
2541 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2545 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2542 |
# the table is emptied by rebuild_zebra.pl script (using the -z switch) |
2546 |
# the table is emptied by rebuild_zebra.pl script (using the -z switch) |
2543 |
my $check_sql = "SELECT COUNT(*) FROM zebraqueue |
2547 |
foreach my $biblionumber ( @$biblionumbers ){ |
2544 |
WHERE server = ? |
2548 |
my $check_sql = "SELECT COUNT(*) FROM zebraqueue |
2545 |
AND biblio_auth_number = ? |
2549 |
WHERE server = ? |
2546 |
AND operation = ? |
2550 |
AND biblio_auth_number = ? |
2547 |
AND done = 0"; |
2551 |
AND operation = ? |
2548 |
my $check_sth = $dbh->prepare_cached($check_sql); |
2552 |
AND done = 0"; |
2549 |
$check_sth->execute( $server, $biblionumber, $op ); |
2553 |
my $check_sth = $dbh->prepare_cached($check_sql); |
2550 |
my ($count) = $check_sth->fetchrow_array; |
2554 |
$check_sth->execute( $server, $biblionumber, $op ); |
2551 |
$check_sth->finish(); |
2555 |
my ($count) = $check_sth->fetchrow_array; |
2552 |
if ( $count == 0 ) { |
2556 |
$check_sth->finish(); |
2553 |
my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); |
2557 |
if ( $count == 0 ) { |
2554 |
$sth->execute( $biblionumber, $server, $op ); |
2558 |
my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); |
2555 |
$sth->finish; |
2559 |
$sth->execute( $biblionumber, $server, $op ); |
|
|
2560 |
$sth->finish; |
2561 |
} |
2556 |
} |
2562 |
} |
2557 |
} |
2563 |
} |
2558 |
|
2564 |
|