View | Details | Raw Unified | Return to bug 10482
Collapse All | Expand All

(-)a/misc/migration_tools/rebuild_zebra.pl (-2 / +42 lines)
Lines 41-46 my $where; Link Here
41
my $offset;
41
my $offset;
42
my $run_as_root;
42
my $run_as_root;
43
my $run_user = (getpwuid($<))[0];
43
my $run_user = (getpwuid($<))[0];
44
my $items_sort;
45
my $items_limit;
44
46
45
my $verbose_logging = 0;
47
my $verbose_logging = 0;
46
my $zebraidx_log_opt = " -v none,fatal,warn ";
48
my $zebraidx_log_opt = " -v none,fatal,warn ";
Lines 65-70 my $result = GetOptions( Link Here
65
    'offset:i'      => \$offset,
67
    'offset:i'      => \$offset,
66
    'v+'             => \$verbose_logging,
68
    'v+'             => \$verbose_logging,
67
    'run-as-root'    => \$run_as_root,
69
    'run-as-root'    => \$run_as_root,
70
    'items-sort:s'     => \$items_sort,
71
    'items-limit:i'  => \$items_limit,
68
);
72
);
69
73
70
if (not $result or $want_help) {
74
if (not $result or $want_help) {
Lines 103-108 if ($process_zebraqueue and $do_not_clear_zebraqueue) { Link Here
103
    die $msg;
107
    die $msg;
104
}
108
}
105
109
110
if (($items_limit or $items_sort) and !$biblios) {
111
    my $msg = "Cannot specify --items_limit or --items_sort without -b\n";
112
    $msg   .= "Please do '$0 --help' to see usage.\n";
113
    die $msg;
114
}
115
106
if ($reset) {
116
if ($reset) {
107
    $noshadow = 1;
117
    $noshadow = 1;
108
}
118
}
Lines 563-569 sub get_raw_marc_record { Link Here
563
            $fetch_sth->finish();
573
            $fetch_sth->finish();
564
            return unless $marc;
574
            return unless $marc;
565
        } else {
575
        } else {
566
            eval { $marc = GetMarcBiblio($record_number, 1); };
576
            eval { $marc = GetMarcBiblio($record_number); };
567
            if ($@ || !$marc) {
577
            if ($@ || !$marc) {
568
                # here we do warn since catching an exception
578
                # here we do warn since catching an exception
569
                # means that the bib was found but failed
579
                # means that the bib was found but failed
Lines 572-577 sub get_raw_marc_record { Link Here
572
                return;
582
                return;
573
            }
583
            }
574
        }
584
        }
585
        add_items_to_biblio($marc, $record_number);
575
    } else {
586
    } else {
576
        eval { $marc = GetAuthority($record_number); };
587
        eval { $marc = GetAuthority($record_number); };
577
        if ($@) {
588
        if ($@) {
Lines 582-587 sub get_raw_marc_record { Link Here
582
    return $marc;
593
    return $marc;
583
}
594
}
584
595
596
sub add_items_to_biblio {
597
    my $record       = shift;
598
    my $biblionumber = shift;
599
    return unless $record && $biblionumber;
600
601
    my $items_query = q{
602
        SELECT itemnumber
603
        FROM items
604
        WHERE biblionumber = ?
605
    };
606
    if ($items_sort) {
607
        $items_query .= q{ ORDER BY } . $items_sort;
608
    }
609
    $items_query .= q{ LIMIT } . $items_limit if ($items_limit);
610
    my $items_sth = $dbh->prepare($items_query);
611
    $items_sth->execute($biblionumber);
612
613
    my @itemnumbers;
614
    while ( my $itemnumber = $items_sth->fetchrow_array ) {
615
        push @itemnumbers, $itemnumber;
616
    }
617
618
    C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, \@itemnumbers )
619
      if (@itemnumbers);
620
}
621
585
sub fix_leader {
622
sub fix_leader {
586
    # FIXME - this routine is suspect
623
    # FIXME - this routine is suspect
587
    # It blanks the Leader/00-05 and Leader/12-16 to
624
    # It blanks the Leader/00-05 and Leader/12-16 to
Lines 745-750 Parameters: Link Here
745
    --where                 let you specify a WHERE query, like itemtype='BOOK'
782
    --where                 let you specify a WHERE query, like itemtype='BOOK'
746
                            or something like that
783
                            or something like that
747
784
785
    --items-sort            items sort column, from items table, and order.
786
                                example: --items-sort "dateaccessioned DESC"
787
    --items-limit 50        max number of items per biblio
788
748
    --munge-config          Deprecated option to try
789
    --munge-config          Deprecated option to try
749
                            to fix Zebra config files.
790
                            to fix Zebra config files.
750
791
751
- 

Return to bug 10482