Bugzilla – Attachment 129451 Details for
Bug 29483
AllowRenewalIfOtherItemsAvailable has poor performance for records with many items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29843: Add ->anonymize and ->filter_by_anonymizable to Koha::Old::Checkouts
Bug-29843-Add--anonymize-and--filterbyanonymizable.patch (text/plain), 2.67 KB, created by
Andrew Fuerste-Henry
on 2022-01-13 20:58:09 UTC
(
hide
)
Description:
Bug 29843: Add ->anonymize and ->filter_by_anonymizable to Koha::Old::Checkouts
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2022-01-13 20:58:09 UTC
Size:
2.67 KB
patch
obsolete
>From c02f7de01e8f4f143dacdae5740d34a6e459b5bd Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 10 Jan 2022 11:23:10 -0300 >Subject: [PATCH] Bug 29843: Add ->anonymize and ->filter_by_anonymizable to > Koha::Old::Checkouts > >This patch implements high-level methods for: > >* Filtering a Koha::Old::Checkouts resultset so only anonymizable rows > are left >* Anonymizing the rows in a resultset > >To test: >1. Apply this patches >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Old/Checkouts.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> > >https://bugs.koha-community.org/show_bug.cgi?id=29483 >--- > Koha/Old/Checkouts.pm | 71 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 71 insertions(+) > >diff --git a/Koha/Old/Checkouts.pm b/Koha/Old/Checkouts.pm >index ec8b223907..5ba2bec6d2 100644 >--- a/Koha/Old/Checkouts.pm >+++ b/Koha/Old/Checkouts.pm >@@ -23,6 +23,51 @@ use Koha::Old::Checkout; > > use base qw(Koha::Objects); > >+=head1 NAME >+ >+Koha::Old::Checkouts - Koha Old Checkouts object set class >+ >+This object represents a set of completed checkouts >+ >+=head1 API >+ >+=head2 Class methods >+ >+=head3 filter_by_anonymizable >+ >+ my $checkouts = $patron->old_checkouts; >+ my $anonymizable_checkouts = $checkouts->filter_by_anonymizable; >+ >+This method filters the resultset, so it only contains checkouts that can be >+anonymized given the patron privacy settings. >+ >+=cut >+ >+sub filter_by_anonymizable { >+ my ( $self, $params ) = @_; >+ >+ my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef; >+ >+ return $self->search( >+ { >+ 'me.borrowernumber' => { 'not' => undef }, >+ 'patron.privacy' => { '<>' => 0 }, >+ ( >+ $anonymous_patron >+ ? ( 'me.borrowernumber' => { '!=' => $anonymous_patron } ) >+ : () >+ ), >+ }, >+ { >+ join => ['patron'], >+ } >+ ); >+} >+ >+=head3 filter_by_todays_checkins >+ >+=cut >+ > sub filter_by_todays_checkins { > my ( $self ) = @_; > >@@ -40,10 +85,36 @@ sub filter_by_todays_checkins { > }); > } > >+=head3 anonymize >+ >+ $patron->old_checkouts->anonymize(); >+ >+Anonymize the given I<Koha::Old::Checkouts> resultset. >+ >+=cut >+ >+sub anonymize { >+ my ( $self, $params ) = @_; >+ >+ my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef; >+ >+ return $self->update( { borrowernumber => $anonymous_id }, { no_triggers => 1 } ); >+} >+ >+=head2 Internal methods >+ >+=head3 _type >+ >+=cut >+ > sub _type { > return 'OldIssue'; > } > >+=head3 object_class >+ >+=cut >+ > sub object_class { > return 'Koha::Old::Checkout'; > } >-- >2.30.2
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 29483
:
127656
|
127819
|
127820
|
127883
|
127884
|
127885
|
129450
|
129451
|
129452
|
129453
|
129454
|
129499
|
129500
|
129501
|
132094
|
132095
|
132096
|
132113
|
133389
|
133390
|
133391
|
134723