Bugzilla – Attachment 130174 Details for
Bug 29984
Remove unused method Koha::Patrons->anonymise_issue_history
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29984: Remove unused method Koha::Patrons->anonymise_issue_history
Bug-29984-Remove-unused-method-KohaPatrons-anonymi.patch (text/plain), 7.03 KB, created by
David Nind
on 2022-02-04 19:25:38 UTC
(
hide
)
Description:
Bug 29984: Remove unused method Koha::Patrons->anonymise_issue_history
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-02-04 19:25:38 UTC
Size:
7.03 KB
patch
obsolete
>From cfbdff661a717f0484e2532bfbe94541102ff0bc Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 4 Feb 2022 15:46:15 -0300 >Subject: [PATCH] Bug 29984: Remove unused method > Koha::Patrons->anonymise_issue_history > >The method is no longer used, and replaced by >Koha::Old::Checkouts->anonymize. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Patrons.t >=> SUCCESS: Tests still pass >3. Run: > $ git grep anonymise_issue_history >=> SUCCESS: The code doesn't mention it >4. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Patrons.pm | 39 ------------------------------- > t/db_dependent/Koha/Patrons.t | 44 +++++++++++++++++++++++++++++++---- > 2 files changed, 39 insertions(+), 44 deletions(-) > >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 81c763cfb7..c498ba55ca 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -158,45 +158,6 @@ sub search_patrons_to_anonymise { > return Koha::Patrons->_new_from_dbic($rs); > } > >-=head3 anonymise_issue_history >- >- Koha::Patrons->search->anonymise_issue_history( { [ before => $older_than_date ] } ); >- >-Anonymise issue history (old_issues) for all patrons older than the given date (optional). >-To make sure all the conditions are met, the caller has the responsibility to >-call search_patrons_to_anonymise to filter the Koha::Patrons set >- >-=cut >- >-sub anonymise_issue_history { >- my ( $self, $params ) = @_; >- >- my $older_than_date = $params->{before}; >- >- $older_than_date = dt_from_string $older_than_date if $older_than_date; >- >- # The default of 0 does not work due to foreign key constraints >- # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry >- # Set it to undef (NULL) >- my $dtf = Koha::Database->new->schema->storage->datetime_parser; >- my $nb_rows = 0; >- while ( my $patron = $self->next ) { >- my $old_issues_to_anonymise = $patron->old_checkouts->search( >- { >- ( >- $older_than_date >- ? ( returndate => >- { '<' => $dtf->format_datetime($older_than_date) } ) >- : () >- ) >- } >- ); >- my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef; >- $nb_rows += $old_issues_to_anonymise->update( { 'old_issues.borrowernumber' => $anonymous_patron } ); >- } >- return $nb_rows; >-} >- > =head3 delete > > Koha::Patrons->search({ some filters here })->delete({ move => 1 }); >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 5737461608..4727d58fa1 100755 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1022,7 +1022,8 @@ subtest 'notice_email_address' => sub { > $patron->delete; > }; > >-subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { >+subtest 'search_patrons_to_anonymise' => sub { >+ > plan tests => 5; > > # TODO create a subroutine in t::lib::Mocks >@@ -1083,7 +1084,16 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > my $patrons_to_anonymise = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->search( { 'me.borrowernumber' => $patron->{borrowernumber} } ); > is( ref($patrons_to_anonymise), 'Koha::Patrons', 'search_patrons_to_anonymise should return Koha::Patrons' ); > >- my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( { before => '2011-11-12' } )->anonymise_issue_history( { before => '2010-10-11' } ); >+ my $rows_affected = Koha::Old::Checkouts->search( >+ { >+ borrowernumber => [ >+ Koha::Patrons->search_patrons_to_anonymise( >+ { before => '2011-11-12' } >+ )->get_column('borrowernumber') >+ ], >+ returndate => { '<' => '2011-10-11', } >+ } >+ )->anonymize; > ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); > > $patrons_to_anonymise = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } ); >@@ -1098,7 +1108,16 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; > is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'The issue should not have been anonymised, the returned date is later' ); > >- $rows_affected = Koha::Patrons->search_patrons_to_anonymise( { before => '2011-11-12' } )->anonymise_issue_history; >+ $rows_affected = Koha::Old::Checkouts->search( >+ { >+ borrowernumber => [ >+ Koha::Patrons->search_patrons_to_anonymise( >+ { before => '2011-11-12' } >+ )->get_column('borrowernumber') >+ ], >+ returndate => { '<' => '2011-11-12', } >+ } >+ )->anonymize; > $sth->execute($item_2->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; > is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'The issue should have been anonymised, the returned date is before' ); >@@ -1106,7 +1125,14 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > my $sth_reset = $dbh->prepare(q|UPDATE old_issues SET borrowernumber = ? WHERE itemnumber = ?|); > $sth_reset->execute( $patron->{borrowernumber}, $item_1->itemnumber ); > $sth_reset->execute( $patron->{borrowernumber}, $item_2->itemnumber ); >- $rows_affected = Koha::Patrons->search_patrons_to_anonymise->anonymise_issue_history; >+ $rows_affected = Koha::Old::Checkouts->search( >+ { >+ borrowernumber => [ >+ Koha::Patrons->search_patrons_to_anonymise->get_column( >+ 'borrowernumber') >+ ] >+ } >+ )->anonymize; > $sth->execute($item_1->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; > is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'The issue 1 should have been anonymised, before parameter was not passed' ); >@@ -1170,7 +1196,15 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > > my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, undef, undef, dt_from_string('2010-10-10') ); > is( $returned, 1, 'The item should have been returned' ); >- my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->anonymise_issue_history( { before => '2010-10-11' } ); >+ my $rows_affected = Koha::Old::Checkouts->search( >+ { >+ borrowernumber => [ >+ Koha::Patrons->search_patrons_to_anonymise( >+ { before => '2010-10-11' } >+ )->get_column('borrowernumber') >+ ] >+ } >+ )->anonymize; > ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); > > my $dbh = C4::Context->dbh; >-- >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 29984
:
130173
|
130174
|
130275