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