From 7a8faeb0c8ee4bb0a07a3475b996c1f361b67638 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 11 Nov 2025 18:52:04 +0000 Subject: [PATCH] Bug 41238: Update progress for peseudonmyzation bacgkround jobs To test: Enable pseudonymization, may need to add bcrypt settings (see bug 28911) Perform some circulations View the jobs (Admin->Manage jobs) Filter for Pseudonymize statistic Note the progress is 0/1 even when job finished Apply patch, restart all Do more circulations Confirm jobs now say 1/1 complete Signed-off-by: David Nind --- Koha/BackgroundJob/PseudonymizeStatistic.pm | 2 ++ t/db_dependent/Koha/BackgroundJob/PseudonymizeStatistic.t | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Koha/BackgroundJob/PseudonymizeStatistic.pm b/Koha/BackgroundJob/PseudonymizeStatistic.pm index 9ab9c18727..963f68287e 100644 --- a/Koha/BackgroundJob/PseudonymizeStatistic.pm +++ b/Koha/BackgroundJob/PseudonymizeStatistic.pm @@ -53,6 +53,8 @@ sub process { my $statistic = $args->{statistic}; my $stat_object = Koha::Statistic->new($statistic); Koha::PseudonymizedTransaction->create_from_statistic($stat_object); + $self->progress(1) + ; #We could use step here, but we are going to save the object during finish and this saves a DB write $self->finish( { data => "" } ); # We want to clear the job data to avoid storing patron information } diff --git a/t/db_dependent/Koha/BackgroundJob/PseudonymizeStatistic.t b/t/db_dependent/Koha/BackgroundJob/PseudonymizeStatistic.t index 9e430df3f2..fa01405913 100755 --- a/t/db_dependent/Koha/BackgroundJob/PseudonymizeStatistic.t +++ b/t/db_dependent/Koha/BackgroundJob/PseudonymizeStatistic.t @@ -68,7 +68,7 @@ subtest 'enqueue() tests' => sub { subtest 'process() tests' => sub { - plan tests => 3; + plan tests => 4; $schema->storage->txn_begin; @@ -103,7 +103,8 @@ subtest 'process() tests' => sub { is( $statistic->{datetime}, $pt_after->last->datetime, "'datetime' column preserved" ); $job->discard_changes; - is( $job->data, '{"data":""}', "Job data cleared after pseudonymization" ); + is( $job->data, '{"data":""}', "Job data cleared after pseudonymization" ); + is( $job->progress, 1, "Job progress is updated" ); $schema->storage->txn_rollback; }; -- 2.39.5