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

(-)a/Koha/BiblioUtils.pm (-2 / +7 lines)
Lines 111-121 The iterator is a Koha::MetadataIterator object. Link Here
111
=cut
111
=cut
112
112
113
sub get_all_biblios_iterator {
113
sub get_all_biblios_iterator {
114
    my ($class, $offset, $length) = @_;
114
    my $database = Koha::Database->new();
115
    my $database = Koha::Database->new();
115
    my $schema   = $database->schema();
116
    my $schema   = $database->schema();
117
116
    my $rs =
118
    my $rs =
117
      $schema->resultset('Biblio')->search( {},
119
        $schema->resultset('Biblio')->search( {},{
118
        { columns => [qw/ biblionumber /] } );
120
            columns => [qw/ biblionumber / ] ,
121
            offset => $offset ,
122
            rows => $length });
123
119
    my $next_func = sub {
124
    my $next_func = sub {
120
        # Warn and skip bad records, otherwise we break the loop
125
        # Warn and skip bad records, otherwise we break the loop
121
        while (1) {
126
        while (1) {
(-)a/Koha/MetadataRecord/Authority.pm (-2 / +6 lines)
Lines 161-171 The iterator is a Koha::MetadataIterator object. Link Here
161
=cut
161
=cut
162
162
163
sub get_all_authorities_iterator {
163
sub get_all_authorities_iterator {
164
    my ($class, $offset, $length) = @_;
164
    my $database = Koha::Database->new();
165
    my $database = Koha::Database->new();
165
    my $schema   = $database->schema();
166
    my $schema   = $database->schema();
166
    my $rs =
167
    my $rs =
167
      $schema->resultset('AuthHeader')->search( { marcxml => { '!=', undef } },
168
        $schema->resultset('AuthHeader')->search( { marcxml => { '!=', undef } },{
168
        { columns => [qw/ authid authtypecode marcxml /] } );
169
            columns => [qw/ authid authtypecode marcxml /],
170
            offset => $offset,
171
            rows => $length });
172
169
    my $next_func = sub {
173
    my $next_func = sub {
170
        my $row = $rs->next();
174
        my $row = $rs->next();
171
        return if !$row;
175
        return if !$row;
(-)a/misc/search_tools/rebuild_elastic_search.pl (-7 / +32 lines)
Lines 28-33 rebuild_elastic_search.pl - inserts records from a Koha database into Elasticsea Link Here
28
B<rebuild_elastic_search.pl>
28
B<rebuild_elastic_search.pl>
29
[B<-c|--commit>=C<count>]
29
[B<-c|--commit>=C<count>]
30
[B<-v|--verbose>]
30
[B<-v|--verbose>]
31
[B<-d|--delete>]
32
[B<-a|--authorities>]
33
[B<-b|--biblios>]
34
[B<-bn|--bnnumber>]
35
[B<--length>]
36
[B<--offset>]
31
[B<-h|--help>]
37
[B<-h|--help>]
32
[B<--man>]
38
[B<--man>]
33
39
Lines 64-69 Only index the supplied biblionumber, mostly for testing purposes. May be Link Here
64
repeated. This also applies to authorities via authid, so if you're using it,
70
repeated. This also applies to authorities via authid, so if you're using it,
65
you probably only want to do one or the other at a time.
71
you probably only want to do one or the other at a time.
66
72
73
=item B<--offset>
74
75
Specify the row number for the first row to be indexed.
76
With this option you have to choose between biblios (-b) or authorities (-a).
77
78
=item B<--length>
79
80
Specify the number of rows to be indexed.
81
With this option you have to choose between biblios (-b) or authorities (-a).
82
67
=item B<-v|--verbose>
83
=item B<-v|--verbose>
68
84
69
By default, this program only emits warnings and errors. This makes it talk
85
By default, this program only emits warnings and errors. This makes it talk
Lines 98-113 my $commit = 5000; Link Here
98
my ($delete, $help, $man);
114
my ($delete, $help, $man);
99
my ($index_biblios, $index_authorities);
115
my ($index_biblios, $index_authorities);
100
my (@biblionumbers);
116
my (@biblionumbers);
117
my ($offset, $length);
101
118
102
$|=1; # flushes output
119
$|=1; # flushes output
103
120
104
GetOptions(
121
GetOptions(
105
    'c|commit=i'       => \$commit,
122
    'c|commit=i'       => \$commit,
106
    'd|delete'         => \$delete,
123
    'd|delete'         => \$delete,
107
    'a|authorities' => \$index_authorities,
124
    'a|authorities'    => \$index_authorities,
108
    'b|biblios' => \$index_biblios,
125
    'b|biblios'        => \$index_biblios,
109
    'bn|bnumber=i' => \@biblionumbers,
126
    'bn|bnumber=i'     => \@biblionumbers,
110
    'v|verbose+'       => \$verbose,
127
    'v|verbose+'       => \$verbose,
128
    'offset=i'         => \$offset,
129
    'length=i'         => \$length,
111
    'h|help'           => \$help,
130
    'h|help'           => \$help,
112
    'man'              => \$man,
131
    'man'              => \$man,
113
);
132
);
Lines 120-125 unless ($index_authorities || $index_biblios) { Link Here
120
pod2usage(1) if $help;
139
pod2usage(1) if $help;
121
pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
140
pod2usage( -exitstatus => 0, -verbose => 2 ) if $man;
122
141
142
if ($offset || $length){
143
    if ( $index_biblios && $index_authorities){
144
        printf "With options --offset or --length, you have to choose between biblios (-b) or authorities (-a)." . "\n";
145
        pod2usage(1);
146
    }
147
}
148
123
sanity_check();
149
sanity_check();
124
150
125
my $next;
151
my $next;
Lines 131-138 if ($index_biblios) { Link Here
131
            return () unless defined $r;
157
            return () unless defined $r;
132
            return ($r, Koha::BiblioUtils->get_from_biblionumber($r, item_data => 1 ));
158
            return ($r, Koha::BiblioUtils->get_from_biblionumber($r, item_data => 1 ));
133
        };
159
        };
134
    } else {
160
    }  else {
135
        my $records = Koha::BiblioUtils->get_all_biblios_iterator();
161
        my $records = Koha::BiblioUtils->get_all_biblios_iterator($offset, $length);
136
        $next = sub {
162
        $next = sub {
137
            $records->next();
163
            $records->next();
138
        }
164
        }
Lines 149-155 if ($index_authorities) { Link Here
149
            return ($r, $a->record);
175
            return ($r, $a->record);
150
        };
176
        };
151
    } else {
177
    } else {
152
        my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator();
178
        my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator($offset, $length);
153
        $next = sub {
179
        $next = sub {
154
            $records->next();
180
            $records->next();
155
        }
181
        }
156
- 

Return to bug 20384