Lines 2539-2559
sub CountItemsIssued {
Link Here
|
2539 |
|
2539 |
|
2540 |
ModZebra( $biblionumber, $op, $server, $record ); |
2540 |
ModZebra( $biblionumber, $op, $server, $record ); |
2541 |
|
2541 |
|
2542 |
$biblionumber is the biblionumber we want to index |
2542 |
$biblionumbers are an arrayref of the biblionumbers we want to index, if single passed we convert to arrayref |
2543 |
|
2543 |
|
2544 |
$op is specialUpdate or recordDelete, and is used to know what we want to do |
2544 |
$op is specialUpdate or recordDelete, and is used to know what we want to do |
2545 |
|
2545 |
|
2546 |
$server is the server that we want to update |
2546 |
$server is the server that we want to update |
2547 |
|
2547 |
|
2548 |
$record is the update MARC record if it's available. If it's not supplied |
2548 |
$records are an arrayref of the updated MARC records if they are available. If they are not supplied |
2549 |
and is needed, it'll be loaded from the database. |
2549 |
and are needed, they will be loaded from the database using $biblionumbers param. If a single record passed we convert to array ref |
2550 |
|
2550 |
|
2551 |
=cut |
2551 |
=cut |
2552 |
|
2552 |
|
2553 |
sub ModZebra { |
2553 |
sub ModZebra { |
2554 |
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs |
2554 |
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs |
2555 |
my ( $biblionumber, $op, $server, $record ) = @_; |
2555 |
my ( $biblionumbers, $op, $server, $records ) = @_; |
2556 |
$debug && warn "ModZebra: update requested for: $biblionumber $op $server\n"; |
2556 |
$biblionumbers = [$biblionumbers] if ref $biblionumbers ne 'ARRAY' && defined $biblionumbers; |
|
|
2557 |
$records = [$records] if ref $biblionumbers ne 'ARRAY' && defined $records; |
2558 |
$debug && warn "ModZebra: updates requested for: @$biblionumbers $op $server\n"; |
2557 |
if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { |
2559 |
if ( C4::Context->preference('SearchEngine') eq 'Elasticsearch' ) { |
2558 |
|
2560 |
|
2559 |
# TODO abstract to a standard API that'll work for whatever |
2561 |
# TODO abstract to a standard API that'll work for whatever |
Lines 2566-2581
sub ModZebra {
Link Here
|
2566 |
} |
2568 |
} |
2567 |
); |
2569 |
); |
2568 |
if ( $op eq 'specialUpdate' ) { |
2570 |
if ( $op eq 'specialUpdate' ) { |
2569 |
unless ($record) { |
2571 |
unless ($records) { |
2570 |
$record = GetMarcBiblio({ |
2572 |
foreach my $biblionumber ( @$biblionumbers ){ |
2571 |
biblionumber => $biblionumber, |
2573 |
my $record = GetMarcBiblio({ |
2572 |
embed_items => 1 }); |
2574 |
biblionumber => $biblionumber, |
|
|
2575 |
embed_items => 1 }); |
2576 |
push @$records, $record; |
2577 |
} |
2573 |
} |
2578 |
} |
2574 |
my $records = [$record]; |
2579 |
$indexer->update_index_background( $biblionumbers, $records ); |
2575 |
$indexer->update_index_background( [$biblionumber], [$record] ); |
|
|
2576 |
} |
2580 |
} |
2577 |
elsif ( $op eq 'recordDelete' ) { |
2581 |
elsif ( $op eq 'recordDelete' ) { |
2578 |
$indexer->delete_index_background( [$biblionumber] ); |
2582 |
$indexer->delete_index_background( $biblionumbers ); |
2579 |
} |
2583 |
} |
2580 |
else { |
2584 |
else { |
2581 |
croak "ModZebra called with unknown operation: $op"; |
2585 |
croak "ModZebra called with unknown operation: $op"; |
Lines 2588-2606
sub ModZebra {
Link Here
|
2588 |
# at the same time |
2592 |
# at the same time |
2589 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2593 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2590 |
# the table is emptied by rebuild_zebra.pl script (using the -z switch) |
2594 |
# the table is emptied by rebuild_zebra.pl script (using the -z switch) |
2591 |
my $check_sql = "SELECT COUNT(*) FROM zebraqueue |
2595 |
foreach my $biblionumber ( @$biblionumbers ){ |
2592 |
WHERE server = ? |
2596 |
my $check_sql = "SELECT COUNT(*) FROM zebraqueue |
2593 |
AND biblio_auth_number = ? |
2597 |
WHERE server = ? |
2594 |
AND operation = ? |
2598 |
AND biblio_auth_number = ? |
2595 |
AND done = 0"; |
2599 |
AND operation = ? |
2596 |
my $check_sth = $dbh->prepare_cached($check_sql); |
2600 |
AND done = 0"; |
2597 |
$check_sth->execute( $server, $biblionumber, $op ); |
2601 |
my $check_sth = $dbh->prepare_cached($check_sql); |
2598 |
my ($count) = $check_sth->fetchrow_array; |
2602 |
$check_sth->execute( $server, $biblionumber, $op ); |
2599 |
$check_sth->finish(); |
2603 |
my ($count) = $check_sth->fetchrow_array; |
2600 |
if ( $count == 0 ) { |
2604 |
$check_sth->finish(); |
2601 |
my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); |
2605 |
if ( $count == 0 ) { |
2602 |
$sth->execute( $biblionumber, $server, $op ); |
2606 |
my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); |
2603 |
$sth->finish; |
2607 |
$sth->execute( $biblionumber, $server, $op ); |
|
|
2608 |
$sth->finish; |
2609 |
} |
2604 |
} |
2610 |
} |
2605 |
} |
2611 |
} |
2606 |
|
2612 |
|