Lines 233-253
sub commit_batch {
Link Here
|
233 |
my ( $num_added, $num_updated, $num_items_added, |
233 |
my ( $num_added, $num_updated, $num_items_added, |
234 |
$num_items_replaced, $num_items_errored, $num_ignored ); |
234 |
$num_items_replaced, $num_items_errored, $num_ignored ); |
235 |
my $schema = Koha::Database->new->schema; |
235 |
my $schema = Koha::Database->new->schema; |
236 |
$schema->storage->txn_do( |
236 |
my $callback = sub { }; |
237 |
sub { |
237 |
if ($runinbackground) { |
238 |
my $callback = sub { }; |
238 |
$job = put_in_background($import_batch_id); |
239 |
if ($runinbackground) { |
239 |
$callback = progress_callback( $job ); |
240 |
$job = put_in_background($import_batch_id); |
240 |
} |
241 |
$callback = progress_callback( $job, $dbh ); |
241 |
( |
242 |
} |
242 |
$num_added, $num_updated, $num_items_added, |
243 |
( |
243 |
$num_items_replaced, $num_items_errored, $num_ignored |
244 |
$num_added, $num_updated, $num_items_added, |
244 |
) |
245 |
$num_items_replaced, $num_items_errored, $num_ignored |
245 |
= BatchCommitRecords( $import_batch_id, $framework, 50, |
246 |
) |
246 |
$callback ); |
247 |
= BatchCommitRecords( $import_batch_id, $framework, 50, |
|
|
248 |
$callback ); |
249 |
} |
250 |
); |
251 |
|
247 |
|
252 |
my $results = { |
248 |
my $results = { |
253 |
did_commit => 1, |
249 |
did_commit => 1, |
Lines 340-350
sub put_in_background {
Link Here
|
340 |
|
336 |
|
341 |
sub progress_callback { |
337 |
sub progress_callback { |
342 |
my $job = shift; |
338 |
my $job = shift; |
343 |
my $dbh = shift; |
|
|
344 |
return sub { |
339 |
return sub { |
345 |
my $progress = shift; |
340 |
my $progress = shift; |
|
|
341 |
my $schema = shift; |
346 |
$job->progress($progress); |
342 |
$job->progress($progress); |
347 |
$dbh->commit(); |
343 |
$schema->txn_commit; |
348 |
} |
344 |
} |
349 |
} |
345 |
} |
350 |
|
346 |
|
351 |
- |
|
|