Bugzilla – Attachment 181859 Details for
Bug 39322
When pseudonymizing don't fetch patron attributes if none are kept
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39322: (follow-up) Further improvements
Bug-39322-follow-up-Further-improvements.patch (text/plain), 2.64 KB, created by
Martin Renvoize (ashimema)
on 2025-05-02 12:56:14 UTC
(
hide
)
Description:
Bug 39322: (follow-up) Further improvements
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-05-02 12:56:14 UTC
Size:
2.64 KB
patch
obsolete
>From 518f89f25aa0d2c61feaded899bd905d8ee06fb2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Fri, 2 May 2025 13:28:46 +0100 >Subject: [PATCH] Bug 39322: (follow-up) Further improvements > >This patch updates the query logic of create_from_statistic for borrower >attributes. > >We replace the count of attributes types with a query to fetch all >attributes type codes where keep_for_pseudonymization is set. > >We then check for content in that array before using it to perform a >filtered search on the patrons extended_attributes to only return >attributes set for pseudonymization. > >This should result in the same skip of extended_attributes fetch should >no attribute types be set to pseudonymization, but it should also reduce >the 1 call to attribute types per attribute the patron has to just a >single filtered call for patron attributes attributes followed by the >store call for each pseudonymizated attribute. > >Test plan: >As before, except there should be even fewer sql calls to the database >than before for the case where there are attributes. >--- > Koha/PseudonymizedTransaction.pm | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > >diff --git a/Koha/PseudonymizedTransaction.pm b/Koha/PseudonymizedTransaction.pm >index cff6ecfe070..b29e1b0a5cc 100644 >--- a/Koha/PseudonymizedTransaction.pm >+++ b/Koha/PseudonymizedTransaction.pm >@@ -98,15 +98,22 @@ sub create_from_statistic { > > $self->store(); > >- if ( $patron && Koha::Patron::Attribute::Types->search( { keep_for_pseudonymization => 1 } )->count > 0 ) { >- my $extended_attributes = $patron->extended_attributes->unblessed; >- for my $attribute (@$extended_attributes) { >- next unless Koha::Patron::Attribute::Types->find( $attribute->{code} )->keep_for_pseudonymization; >+ if ($patron) { >+ my @kept_types = Koha::Patron::Attribute::Types->search( >+ { keep_for_pseudonymization => 1 }, >+ { columns => ['code'] } >+ )->get_column('code'); >+ >+ if (@kept_types) { >+ my $extended_attributes = >+ $patron->extended_attributes->search( { code => { -in => \@kept_types } } )->unblessed; > >- delete $attribute->{id}; >- delete $attribute->{borrowernumber}; >+ for my $attribute (@$extended_attributes) { >+ delete $attribute->{id}; >+ delete $attribute->{borrowernumber}; > >- $self->_result->create_related( 'pseudonymized_borrower_attributes', $attribute ); >+ $self->_result->create_related( 'pseudonymized_borrower_attributes', $attribute ); >+ } > } > } > >-- >2.49.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39322
:
179240
|
180109
|
181858
|
181859
|
181863