From 1faae4081c493936aa5ad4101be10875100e3e47 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 5 Apr 2022 10:53:12 +0200 Subject: [PATCH] Bug 30360: Make UpdateElasticIndex use the helper methods Signed-off-by: Tomas Cohen Arazi --- Koha/BackgroundJob/UpdateElasticIndex.pm | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/Koha/BackgroundJob/UpdateElasticIndex.pm b/Koha/BackgroundJob/UpdateElasticIndex.pm index df98f6e085..585393920d 100644 --- a/Koha/BackgroundJob/UpdateElasticIndex.pm +++ b/Koha/BackgroundJob/UpdateElasticIndex.pm @@ -17,10 +17,6 @@ package Koha::BackgroundJob::UpdateElasticIndex; use Modern::Perl; -use JSON qw( encode_json decode_json ); - -use Koha::DateUtils qw( dt_from_string ); - use base 'Koha::BackgroundJob'; =head1 NAME @@ -52,14 +48,7 @@ Process the modification. sub process { my ( $self, $args ) = @_; - # 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; - $self->started_on(dt_from_string) - ->progress($job_progress) - ->status('started') - ->store; + $self->start; my @record_ids = @{ $args->{record_ids} }; my $record_server = $args->{record_server}; @@ -90,14 +79,11 @@ sub process { $report->{total_success} = scalar @record_ids; } - my $job_data = decode_json $self->data; - $job_data->{messages} = \@messages; - $job_data->{report} = $report; + my $data = $self->decoded_data; + $data->{messages} = \@messages; + $data->{report} = $report; - $self->ended_on(dt_from_string) - ->data(encode_json $job_data); - $self->status('finished') if $self->status ne 'cancelled'; - $self->store; + $self->finish( $data ); } =head3 enqueue -- 2.35.1