Lines 16-27
package Koha::BackgroundJob::UpdateElasticIndex;
Link Here
|
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
|
|
19 |
|
19 |
use JSON qw( encode_json decode_json ); |
20 |
use JSON qw( encode_json decode_json ); |
20 |
|
21 |
|
21 |
use Koha::BackgroundJobs; |
|
|
22 |
use Koha::DateUtils qw( dt_from_string ); |
22 |
use Koha::DateUtils qw( dt_from_string ); |
23 |
use C4::Biblio; |
|
|
24 |
use C4::MarcModificationTemplates; |
25 |
|
23 |
|
26 |
use base 'Koha::BackgroundJob'; |
24 |
use base 'Koha::BackgroundJob'; |
27 |
|
25 |
|
Lines 54-70
Process the modification.
Link Here
|
54 |
sub process { |
52 |
sub process { |
55 |
my ( $self, $args ) = @_; |
53 |
my ( $self, $args ) = @_; |
56 |
|
54 |
|
57 |
my $job = Koha::BackgroundJobs->find( $args->{job_id} ); |
|
|
58 |
|
59 |
if ( !exists $args->{job_id} || !$job || $job->status eq 'cancelled' ) { |
60 |
return; |
61 |
} |
62 |
|
63 |
# FIXME If the job has already been started, but started again (worker has been restart for instance) |
55 |
# FIXME If the job has already been started, but started again (worker has been restart for instance) |
64 |
# Then we will start from scratch and so double process the same records |
56 |
# Then we will start from scratch and so double process the same records |
65 |
|
57 |
|
66 |
my $job_progress = 0; |
58 |
my $job_progress = 0; |
67 |
$job->started_on(dt_from_string) |
59 |
$self->started_on(dt_from_string) |
68 |
->progress($job_progress) |
60 |
->progress($job_progress) |
69 |
->status('started') |
61 |
->status('started') |
70 |
->store; |
62 |
->store; |
Lines 98-111
sub process {
Link Here
|
98 |
$report->{total_success} = scalar @record_ids; |
90 |
$report->{total_success} = scalar @record_ids; |
99 |
} |
91 |
} |
100 |
|
92 |
|
101 |
my $job_data = decode_json $job->data; |
93 |
my $job_data = decode_json $self->data; |
102 |
$job_data->{messages} = \@messages; |
94 |
$job_data->{messages} = \@messages; |
103 |
$job_data->{report} = $report; |
95 |
$job_data->{report} = $report; |
104 |
|
96 |
|
105 |
$job->ended_on(dt_from_string) |
97 |
$self->ended_on(dt_from_string) |
106 |
->data(encode_json $job_data); |
98 |
->data(encode_json $job_data); |
107 |
$job->status('finished') if $job->status ne 'cancelled'; |
99 |
$self->status('finished') if $self->status ne 'cancelled'; |
108 |
$job->store; |
100 |
$self->store; |
109 |
} |
101 |
} |
110 |
|
102 |
|
111 |
=head3 enqueue |
103 |
=head3 enqueue |
112 |
- |
|
|