From d7d99ded1fe5ce47af333a561fa31e9910bcfdff Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 19 Aug 2022 07:54:55 +0000 Subject: [PATCH] Bug 27421: (QA follow-up) WIP: Adjusting progress and size Content-Type: text/plain; charset=utf-8 Might still need a bit of polishing. --- Koha/BackgroundJob/MARCImportCommitBatch.pm | 8 ++++---- Koha/BackgroundJob/MARCImportRevertBatch.pm | 10 ++++++---- Koha/BackgroundJob/StageMARCForImport.pm | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Koha/BackgroundJob/MARCImportCommitBatch.pm b/Koha/BackgroundJob/MARCImportCommitBatch.pm index 57faa99c51..94d492e732 100644 --- a/Koha/BackgroundJob/MARCImportCommitBatch.pm +++ b/Koha/BackgroundJob/MARCImportCommitBatch.pm @@ -65,14 +65,14 @@ sub process { my ( $num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored ); try { - my $size = Koha::Import::Records->search({ import_batch_id => $import_batch_id })->count; - $self->size($size)->store; ( $num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored ) = BatchCommitRecords( $import_batch_id, $frameworkcode, 50, sub { my $job_progress = shift; $self->progress( $job_progress )->store } ); + my $count = $num_added + $num_updated; + $self->set({ progress => $count, size => $count })->store if $count; } catch { warn $_; @@ -106,8 +106,8 @@ sub enqueue { my ( $self, $args) = @_; $self->SUPER::enqueue({ - job_size => 0, # unknown for now - job_args => $args + job_size => Koha::Import::Records->search({ import_batch_id => $args->{import_batch_id} })->count, + job_args => $args, }); } diff --git a/Koha/BackgroundJob/MARCImportRevertBatch.pm b/Koha/BackgroundJob/MARCImportRevertBatch.pm index bd125a07e8..d6d88bea1a 100644 --- a/Koha/BackgroundJob/MARCImportRevertBatch.pm +++ b/Koha/BackgroundJob/MARCImportRevertBatch.pm @@ -23,6 +23,7 @@ use base 'Koha::BackgroundJob'; use C4::ImportBatch qw( BatchRevertRecords ); +use Koha::Import::Records; =head1 NAME @@ -68,8 +69,9 @@ sub process { ( $num_deleted, $num_errors, $num_reverted, $num_items_deleted, $num_ignored - ) = BatchRevertRecords( $import_batch_id, 50, - sub { my $job_progress = shift; $self->progress( $job_progress )->store } ); + ) = BatchRevertRecords( $import_batch_id ); # TODO BatchRevertRecords still needs a progress_callback + my $count = $num_deleted + $num_reverted; + $self->set({ progress => $count, size => $count })->store if $count; } catch { warn $_; @@ -103,8 +105,8 @@ sub enqueue { my ( $self, $args) = @_; $self->SUPER::enqueue({ - job_size => 0, # unknown for now - job_args => $args + job_size => Koha::Import::Records->search({ import_batch_id => $args->{import_batch_id} })->count, + job_args => $args, }); } diff --git a/Koha/BackgroundJob/StageMARCForImport.pm b/Koha/BackgroundJob/StageMARCForImport.pm index a2c12a78fd..853530587e 100644 --- a/Koha/BackgroundJob/StageMARCForImport.pm +++ b/Koha/BackgroundJob/StageMARCForImport.pm @@ -125,6 +125,7 @@ sub process { $self->progress( int($job_progress) )->store; } ); + $self->set({ progress => $num_valid, size => $num_valid })->store if $num_valid; if ($profile_id) { my $ibatch = Koha::ImportBatches->find($batch_id); -- 2.20.1