Lines 170-175
Top level function that turns reserves into tmp_holdsqueue and hold_fill_targets
Link Here
|
170 |
sub CreateQueue { |
170 |
sub CreateQueue { |
171 |
my $params = shift; |
171 |
my $params = shift; |
172 |
my $unallocated = $params->{unallocated}; |
172 |
my $unallocated = $params->{unallocated}; |
|
|
173 |
my $loops = $params->{loops} || 1; |
173 |
my $dbh = C4::Context->dbh; |
174 |
my $dbh = C4::Context->dbh; |
174 |
|
175 |
|
175 |
unless ($unallocated) { |
176 |
unless ($unallocated) { |
Lines 187-193
sub CreateQueue {
Link Here
|
187 |
my $use_transport_cost_matrix = C4::Context->preference("UseTransportCostMatrix"); |
188 |
my $use_transport_cost_matrix = C4::Context->preference("UseTransportCostMatrix"); |
188 |
if ($use_transport_cost_matrix) { |
189 |
if ($use_transport_cost_matrix) { |
189 |
$transport_cost_matrix = TransportCostMatrix(); |
190 |
$transport_cost_matrix = TransportCostMatrix(); |
190 |
unless (keys %$transport_cost_matrix) { |
191 |
unless ( keys %$transport_cost_matrix ) { |
191 |
warn "UseTransportCostMatrix set to yes, but matrix not populated"; |
192 |
warn "UseTransportCostMatrix set to yes, but matrix not populated"; |
192 |
undef $transport_cost_matrix; |
193 |
undef $transport_cost_matrix; |
193 |
} |
194 |
} |
Lines 197-221
sub CreateQueue {
Link Here
|
197 |
|
198 |
|
198 |
my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests(); |
199 |
my $bibs_with_pending_requests = GetBibsWithPendingHoldRequests(); |
199 |
|
200 |
|
200 |
foreach my $biblionumber (@$bibs_with_pending_requests) { |
201 |
# Split the list of bibs into chunks to run in parallel |
|
|
202 |
my @chunks; |
203 |
if ( $loops > 1 ) { |
204 |
my $i = 0; |
205 |
while (@$bibs_with_pending_requests) { |
206 |
push( @{ $chunks[$i] }, pop(@$bibs_with_pending_requests) ); |
201 |
|
207 |
|
202 |
$total_bibs++; |
208 |
$i++; |
|
|
209 |
$i = 0 if $i >= $loops; |
210 |
} |
203 |
|
211 |
|
204 |
my $result = update_queue_for_biblio( |
212 |
my $pm = Parallel::ForkManager->new($loops); |
205 |
{ |
213 |
|
206 |
biblio_id => $biblionumber, |
214 |
DATA_LOOP: |
207 |
branches_to_use => $branches_to_use, |
215 |
foreach my $chunk (@chunks) { |
208 |
transport_cost_matrix => $transport_cost_matrix, |
216 |
my $pid = $pm->start and next DATA_LOOP; |
209 |
unallocated => $unallocated |
217 |
foreach my $biblionumber (@$chunk) { |
|
|
218 |
update_queue_for_biblio( |
219 |
{ |
220 |
biblio_id => $biblionumber, |
221 |
branches_to_use => $branches_to_use, |
222 |
transport_cost_matrix => $transport_cost_matrix, |
223 |
unallocated => $unallocated |
224 |
} |
225 |
); |
210 |
} |
226 |
} |
211 |
); |
227 |
$pm->finish; |
|
|
228 |
} |
212 |
|
229 |
|
213 |
$total_requests += $result->{requests}; |
230 |
$pm->wait_all_children; |
214 |
$total_available_items += $result->{available_items}; |
231 |
} else { |
215 |
$num_items_mapped += $result->{mapped_items}; |
232 |
foreach my $biblionumber (@$bibs_with_pending_requests) { |
|
|
233 |
update_queue_for_biblio( |
234 |
{ |
235 |
biblio_id => $biblionumber, |
236 |
branches_to_use => $branches_to_use, |
237 |
transport_cost_matrix => $transport_cost_matrix, |
238 |
unallocated => $unallocated |
239 |
} |
240 |
); |
241 |
} |
216 |
} |
242 |
} |
217 |
} |
243 |
} |
218 |
|
244 |
|
|
|
245 |
|
219 |
=head2 GetBibsWithPendingHoldRequests |
246 |
=head2 GetBibsWithPendingHoldRequests |
220 |
|
247 |
|
221 |
my $biblionumber_aref = GetBibsWithPendingHoldRequests(); |
248 |
my $biblionumber_aref = GetBibsWithPendingHoldRequests(); |