Bugzilla – Attachment 129259 Details for
Bug 29525
Privacy settings for patrons should also affect holds history
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29525: Make batch_anonymise.pl deal with holds
Bug-29525-Make-batchanonymisepl-deal-with-holds.patch (text/plain), 2.74 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-01-10 13:17:29 UTC
(
hide
)
Description:
Bug 29525: Make batch_anonymise.pl deal with holds
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-01-10 13:17:29 UTC
Size:
2.74 KB
patch
obsolete
>From 202e7c3cc7943d19f110f945b116f6f421b0cd5b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 3 Jan 2022 15:08:27 -0300 >Subject: [PATCH] Bug 29525: Make batch_anonymise.pl deal with holds > >This patch makes the batch_anonymise.pl script handle holds too. It does >so by leveraging on the newly introduced method 'filter_by_anonymizable' >and also 'anonymize'. > >To test: >1. Have a patron with two past holds. >2. Make sure they are a few days back: > $ koha-mysql kohadev > > UPDATE old_reserves SET timestamp=ADDDATE(NOW(), INTERVAL -4 DAY); >3. Run: > $ kshell > k$ perl misc/cronjobs/batch_anonymise.pl --days 2 -v >=> SUCCESS: You see something like: >Checkouts and holds before 2022-01-01 will be anonymised. >0 checkouts anonymised. >2 holds anonymised. >4. Repeat 3 >=> SUCCESS: They are already anonymized. You see >Checkouts and holds before 2022-01-01 will be anonymised. >0 checkouts anonymised. >0 holds anonymised. >5. Sign off :-D >--- > misc/cronjobs/batch_anonymise.pl | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) > >diff --git a/misc/cronjobs/batch_anonymise.pl b/misc/cronjobs/batch_anonymise.pl >index edea4fa7ed..c0a17407d6 100755 >--- a/misc/cronjobs/batch_anonymise.pl >+++ b/misc/cronjobs/batch_anonymise.pl >@@ -17,15 +17,19 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-use strict; >-use warnings; >+use Modern::Perl; > > use Koha::Script -cron; >+ > use C4::Context; >+use C4::Log qw( cronlogaction ); >+ >+use Koha::Database; >+use Koha::DateUtils qw(dt_from_string); > use Koha::Patrons; >+ > use Date::Calc qw( Add_Delta_Days Today ); > use Getopt::Long qw( GetOptions ); >-use C4::Log qw( cronlogaction ); > > sub usage { > print STDERR <<USAGE; >@@ -58,12 +62,26 @@ if ( !$days ) { > > cronlogaction(); > >+my $dtf = Koha::Database->new->schema->storage->datetime_parser; >+ > my ($year,$month,$day) = Today(); > my ($newyear,$newmonth,$newday) = Add_Delta_Days ($year,$month,$day,(-1)*$days); > my $formatdate = sprintf "%4d-%02d-%02d",$newyear,$newmonth,$newday; >-$verbose and print "Checkouts before $formatdate will be anonymised.\n"; >+$verbose and print "Checkouts and holds before $formatdate will be anonymised.\n"; > > my $rows = Koha::Patrons->search_patrons_to_anonymise( { before => $formatdate } )->anonymise_issue_history( { before => $formatdate } ); > $verbose and print int($rows) . " checkouts anonymised.\n"; > >+$rows = Koha::Old::Holds->filter_by_anonymizable->search( >+ { >+ timestamp => { >+ '<' => $dtf->format_datetime( >+ dt_from_string()->subtract( days => $days ) >+ ) >+ } >+ } >+)->anonymize; >+ >+$verbose and print int($rows) . " holds anonymised.\n"; >+ > exit(0); >-- >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 29525
:
128975
|
128976
|
128977
|
129258
|
129259
|
129260
|
129265
|
129266
|
129267
|
129268
|
129273
|
129321
|
129322
|
129323
|
129363
|
129364
|
129424
|
129425
|
129426
|
129427
|
129428
|
129432
|
129433
|
129434
|
129435
|
129436
|
129544
|
129545
|
130254
|
130255
|
130256
|
130257
|
130258