Lines 191-197
sub index_records {
Link Here
|
191 |
my ($record_type, $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $server_dir) = @_; |
191 |
my ($record_type, $directory, $skip_export, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $server_dir) = @_; |
192 |
|
192 |
|
193 |
my $num_records_exported = 0; |
193 |
my $num_records_exported = 0; |
194 |
my $num_records_deleted = 0; |
194 |
my $records_deleted; |
195 |
my $need_reset = check_zebra_dirs($server_dir); |
195 |
my $need_reset = check_zebra_dirs($server_dir); |
196 |
if ($need_reset) { |
196 |
if ($need_reset) { |
197 |
print "$0: found broken zebra server directories: forcing a rebuild\n"; |
197 |
print "$0: found broken zebra server directories: forcing a rebuild\n"; |
Lines 212-223
sub index_records {
Link Here
|
212 |
if ($process_zebraqueue) { |
212 |
if ($process_zebraqueue) { |
213 |
my $entries = select_zebraqueue_records($record_type, 'deleted'); |
213 |
my $entries = select_zebraqueue_records($record_type, 'deleted'); |
214 |
mkdir "$directory/del_$record_type" unless (-d "$directory/del_$record_type"); |
214 |
mkdir "$directory/del_$record_type" unless (-d "$directory/del_$record_type"); |
215 |
$num_records_deleted = generate_deleted_marc_records($record_type, $entries, "$directory/del_$record_type", $as_xml); |
215 |
$records_deleted = generate_deleted_marc_records($record_type, $entries, "$directory/del_$record_type", $as_xml); |
216 |
mark_zebraqueue_batch_done($entries); |
216 |
mark_zebraqueue_batch_done($entries); |
217 |
$entries = select_zebraqueue_records($record_type, 'updated'); |
217 |
$entries = select_zebraqueue_records($record_type, 'updated'); |
218 |
mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type"); |
218 |
mkdir "$directory/upd_$record_type" unless (-d "$directory/upd_$record_type"); |
219 |
$num_records_exported = export_marc_records_from_list($record_type, |
219 |
$num_records_exported = export_marc_records_from_list($record_type, |
220 |
$entries, "$directory/upd_$record_type", $as_xml, $noxml); |
220 |
$entries, "$directory/upd_$record_type", $as_xml, $noxml, $records_deleted); |
221 |
mark_zebraqueue_batch_done($entries); |
221 |
mark_zebraqueue_batch_done($entries); |
222 |
} else { |
222 |
} else { |
223 |
my $sth = select_all_records($record_type); |
223 |
my $sth = select_all_records($record_type); |
Lines 239-245
sub index_records {
Link Here
|
239 |
my $record_fmt = ($as_xml) ? 'marcxml' : 'iso2709' ; |
239 |
my $record_fmt = ($as_xml) ? 'marcxml' : 'iso2709' ; |
240 |
if ($process_zebraqueue) { |
240 |
if ($process_zebraqueue) { |
241 |
do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) |
241 |
do_indexing($record_type, 'delete', "$directory/del_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) |
242 |
if $num_records_deleted; |
242 |
if %$records_deleted; |
243 |
do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) |
243 |
do_indexing($record_type, 'update', "$directory/upd_$record_type", $reset, $noshadow, $record_fmt, $zebraidx_log_opt) |
244 |
if $num_records_exported; |
244 |
if $num_records_exported; |
245 |
} else { |
245 |
} else { |
Lines 366-377
sub export_marc_records_from_sth {
Link Here
|
366 |
} |
366 |
} |
367 |
|
367 |
|
368 |
sub export_marc_records_from_list { |
368 |
sub export_marc_records_from_list { |
369 |
my ($record_type, $entries, $directory, $as_xml, $noxml) = @_; |
369 |
my ($record_type, $entries, $directory, $as_xml, $noxml, $records_deleted) = @_; |
370 |
|
370 |
|
371 |
my $num_exported = 0; |
371 |
my $num_exported = 0; |
372 |
open (OUT, ">:utf8 ", "$directory/exported_records") or die $!; |
372 |
open (OUT, ">:utf8 ", "$directory/exported_records") or die $!; |
373 |
my $i = 0; |
373 |
my $i = 0; |
374 |
my %found = (); |
374 |
|
|
|
375 |
# Skip any deleted records. We check for this anyway, but this reduces error spam |
376 |
my %found = %$records_deleted; |
375 |
foreach my $record_number ( map { $_->{biblio_auth_number} } |
377 |
foreach my $record_number ( map { $_->{biblio_auth_number} } |
376 |
grep { !$found{ $_->{biblio_auth_number} }++ } |
378 |
grep { !$found{ $_->{biblio_auth_number} }++ } |
377 |
@$entries ) { |
379 |
@$entries ) { |
Lines 396-402
sub export_marc_records_from_list {
Link Here
|
396 |
sub generate_deleted_marc_records { |
398 |
sub generate_deleted_marc_records { |
397 |
my ($record_type, $entries, $directory, $as_xml) = @_; |
399 |
my ($record_type, $entries, $directory, $as_xml) = @_; |
398 |
|
400 |
|
399 |
my $num_exported = 0; |
401 |
my $records_deleted = {}; |
400 |
open (OUT, ">:utf8 ", "$directory/exported_records") or die $!; |
402 |
open (OUT, ">:utf8 ", "$directory/exported_records") or die $!; |
401 |
my $i = 0; |
403 |
my $i = 0; |
402 |
foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) { |
404 |
foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) { |
Lines 414-424
sub generate_deleted_marc_records {
Link Here
|
414 |
} |
416 |
} |
415 |
|
417 |
|
416 |
print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference("marcflavour")) : $marc->as_usmarc(); |
418 |
print OUT ($as_xml) ? $marc->as_xml_record(C4::Context->preference("marcflavour")) : $marc->as_usmarc(); |
417 |
$num_exported++; |
419 |
|
|
|
420 |
$records_deleted->{$record_number} = 1; |
418 |
} |
421 |
} |
419 |
print "\nRecords exported: $num_exported\n" if ( $verbose_logging ); |
422 |
print "\nRecords exported: $i\n" if ( $verbose_logging ); |
420 |
close OUT; |
423 |
close OUT; |
421 |
return $num_exported; |
424 |
return $records_deleted; |
422 |
|
425 |
|
423 |
|
426 |
|
424 |
} |
427 |
} |
425 |
- |
|
|