Bugzilla – Attachment 129439 Details for
Bug 29843
Add ->anonymize and ->filter_by_anonymizable to Koha::Old::Checkouts
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.55 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-01-13 19:21:57 UTC
(
hide
)
Description:
Bug 29843: Add ->anonymize and ->filter_by_anonymizable to Koha::Old::Checkouts
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-01-13 19:21:57 UTC
Size:
2.55 KB
patch
obsolete
>From 36f436c051179910abaa8a89480b8c7ca75809bd 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 >--- > 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.32.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 29843
:
129269
|
129270
|
129271
|
129272
|
129274
|
129275
|
129276
|
129277
|
129278
|
129438
|
129439
|
129440
|
129441
|
129442
|
129445
|
129446
|
129447
|
129448
|
129449
|
129475
|
129476
|
129477
|
129478
|
129479
|
129492
|
129493
|
129494
|
129495
|
129496
|
130264
|
130265
|
130266
|
130267
|
130268
|
130335