Lines 14-23
sub process {
Link Here
|
14 |
|
14 |
|
15 |
my $job_type = $args->{job_type}; |
15 |
my $job_type = $args->{job_type}; |
16 |
|
16 |
|
17 |
return unless exists $args->{job_id}; |
|
|
18 |
|
19 |
my $job = Koha::BackgroundJobs->find( $args->{job_id} ); |
17 |
my $job = Koha::BackgroundJobs->find( $args->{job_id} ); |
20 |
|
18 |
|
|
|
19 |
if ( !exists $args->{job_id} || !$job || $job->status eq 'cancelled' ) { |
20 |
$channel->ack; |
21 |
return; |
22 |
} |
23 |
|
21 |
my $job_progress = 0; |
24 |
my $job_progress = 0; |
22 |
$job->started_on(dt_from_string) |
25 |
$job->started_on(dt_from_string) |
23 |
->progress($job_progress) |
26 |
->progress($job_progress) |
Lines 29-42
sub process {
Link Here
|
29 |
my @record_ids = @{ $args->{record_ids} }; |
32 |
my @record_ids = @{ $args->{record_ids} }; |
30 |
|
33 |
|
31 |
my $report = { |
34 |
my $report = { |
32 |
total_records => 0, |
35 |
total_records => scalar @record_ids, |
33 |
total_success => 0, |
36 |
total_success => 0, |
34 |
}; |
37 |
}; |
35 |
my @messages; |
38 |
my @messages; |
36 |
my $dbh = C4::Context->dbh; |
39 |
my $dbh = C4::Context->dbh; |
37 |
$dbh->{RaiseError} = 1; |
40 |
$dbh->{RaiseError} = 1; |
38 |
RECORD_IDS: for my $biblionumber ( sort { $a <=> $b } @record_ids ) { |
41 |
RECORD_IDS: for my $biblionumber ( sort { $a <=> $b } @record_ids ) { |
39 |
$report->{total_records}++; |
42 |
|
|
|
43 |
last if $job->get_from_storage->status eq 'cancelled'; |
44 |
|
40 |
next unless $biblionumber; |
45 |
next unless $biblionumber; |
41 |
|
46 |
|
42 |
# Modify the biblio |
47 |
# Modify the biblio |
Lines 69-77
sub process {
Link Here
|
69 |
$job_data->{report} = $report; |
74 |
$job_data->{report} = $report; |
70 |
|
75 |
|
71 |
$job->ended_on(dt_from_string) |
76 |
$job->ended_on(dt_from_string) |
72 |
->status('finished') |
77 |
->data(encode_json $job_data); |
73 |
->data(encode_json $job_data) |
78 |
$job->status('finished') if $job->status ne 'cancelled'; |
74 |
->store; |
79 |
$job->store; |
75 |
$channel->ack(); # FIXME Is that ok even on failure? |
80 |
$channel->ack(); # FIXME Is that ok even on failure? |
76 |
} |
81 |
} |
77 |
|
82 |
|