From a5d5a445845c3d005306cda551f814e5ae733355 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 1 Apr 2022 12:25:56 +0200 Subject: [PATCH] Bug 27344: Adapt to bug 30181 changes Signed-off-by: Tomas Cohen Arazi --- Koha/BackgroundJob/UpdateElasticIndex.pm | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Koha/BackgroundJob/UpdateElasticIndex.pm b/Koha/BackgroundJob/UpdateElasticIndex.pm index 700c1e0854..df98f6e085 100644 --- a/Koha/BackgroundJob/UpdateElasticIndex.pm +++ b/Koha/BackgroundJob/UpdateElasticIndex.pm @@ -16,12 +16,10 @@ package Koha::BackgroundJob::UpdateElasticIndex; # along with Koha; if not, see . use Modern::Perl; + use JSON qw( encode_json decode_json ); -use Koha::BackgroundJobs; use Koha::DateUtils qw( dt_from_string ); -use C4::Biblio; -use C4::MarcModificationTemplates; use base 'Koha::BackgroundJob'; @@ -54,17 +52,11 @@ Process the modification. sub process { my ( $self, $args ) = @_; - my $job = Koha::BackgroundJobs->find( $args->{job_id} ); - - if ( !exists $args->{job_id} || !$job || $job->status eq 'cancelled' ) { - return; - } - # FIXME If the job has already been started, but started again (worker has been restart for instance) # Then we will start from scratch and so double process the same records my $job_progress = 0; - $job->started_on(dt_from_string) + $self->started_on(dt_from_string) ->progress($job_progress) ->status('started') ->store; @@ -98,14 +90,14 @@ sub process { $report->{total_success} = scalar @record_ids; } - my $job_data = decode_json $job->data; + my $job_data = decode_json $self->data; $job_data->{messages} = \@messages; $job_data->{report} = $report; - $job->ended_on(dt_from_string) + $self->ended_on(dt_from_string) ->data(encode_json $job_data); - $job->status('finished') if $job->status ne 'cancelled'; - $job->store; + $self->status('finished') if $self->status ne 'cancelled'; + $self->store; } =head3 enqueue -- 2.35.1