From 4ba56dc75f230c1c637353f00b2d2e7b431b1a71 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 19 Feb 2025 14:44:34 +0000 Subject: [PATCH] Bug 37901: Add ILL pseudonymization 1) Apply patches 2) Add a under in /etc/koha/sites/kohadev/koha.conf.xml: $ $2a$08$9lmorEKnwQloheaCLFIfje 3) Restart plack & worker: $ koha-plack --restart kohadev && sudo koha-worker --restart kohadev 4) Enable ILLModule and Pseudonymization system preferences 5) Create an ILL request 6) Confirm the pseudonymized_transaction has been added: $ koha-mysql kohadev $ select * from pseudonymized_transactions; 7) Further testing with more data: Check all options from PseudonymizationPatronFields and PseudonymizationTransactionFields and repeat steps 5) and 6). --- Koha/ILL/Request.pm | 16 ++++++++++++++++ Koha/Statistic.pm | 9 ++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 90035032e42..783ecb45e11 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -2009,6 +2009,7 @@ possibly records the fact that something happened sub store { my ( $self, $attrs ) = @_; + my $is_new_request = !$self->in_storage; my %updated_columns = $self->_result->get_dirty_columns; my @holds; @@ -2049,6 +2050,21 @@ sub store { ); } + return $ret unless $is_new_request; + + C4::Stats::UpdateStats( + { + borrowernumber => $self->borrowernumber // undef, + branch => $self->branchcode, + categorycode => $self->patron ? $self->patron->categorycode : undef, + ccode => undef, + itemnumber => undef, + itemtype => undef, + location => undef, + type => 'ill_request', + } + ); + return $ret; } diff --git a/Koha/Statistic.pm b/Koha/Statistic.pm index c28a1e0d2b0..37b695cc160 100644 --- a/Koha/Statistic.pm +++ b/Koha/Statistic.pm @@ -27,8 +27,9 @@ use Koha::BackgroundJob::PseudonymizeStatistic; use base qw(Koha::Object); -our @allowed_accounts_types = qw( writeoff payment ); -our @allowed_circulation_types = qw( renew issue localuse return onsite_checkout recall item_found item_lost ); +our @allowed_accounts_types = qw( writeoff payment ); +our @allowed_circulation_types = + qw( renew issue localuse return onsite_checkout recall item_found item_lost ill_request ); our @mandatory_accounts_keys = qw( type branch borrowernumber value ); # note that amount is mapped to value our @mandatory_circulation_keys = qw( type branch borrowernumber itemnumber ccode itemtype ); @@ -149,7 +150,9 @@ Generate a pesudonymized version of the statistic. sub pseudonymize { my ($self) = @_; - return unless ( $self->borrowernumber && grep { $_ eq $self->type } qw(renew issue return onsite_checkout) ); + return + unless ( $self->borrowernumber && grep { $_ eq $self->type } + qw(renew issue return onsite_checkout ill_request) ); # FIXME When getting the object from svc/renewal we get a DateTime object # normally we just fetch from DB to clear this, but statistics has no primary key -- 2.39.5