From d2b821583f4b111f3cd365ba24337650def5fb6a Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 19 Mar 2021 08:11:27 +0000 Subject: [PATCH] Bug 21549: (follow-up) Switch to filter_by See QA remarks. Test plan: Run t/db_dependent/Koha/Patrons.t Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens --- Koha/Patrons.pm | 6 +++--- misc/cronjobs/cleanup_database.pl | 2 +- t/db_dependent/Koha/Patrons.t | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm index 9a3977704f..97fac5e60d 100644 --- a/Koha/Patrons.pm +++ b/Koha/Patrons.pm @@ -233,15 +233,15 @@ sub delete { return $patrons_deleted; } -=head3 search_expired +=head3 filter_by_dateexpiry - Koha::Patrons->search_expired{{ days => $x }); + Koha::Patrons->filter_by_dateexpiry{{ days => $x }); Returns set of Koha patron objects expired $x days. =cut -sub search_expired { +sub filter_by_dateexpiry { my ( $class, $params ) = @_; my $days = $params->{days} || 0; my $parser = Koha::Database->new->schema->storage->datetime_parser; diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 07bd2622f9..10ff3e6985 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -404,7 +404,7 @@ if($allDebarments) { my $days = C4::Context->preference('LockExpiredDelay'); if( defined $days && $days ne q{} ) { say "Start locking expired patrons" if $verbose; - my $expired_patrons = Koha::Patrons->search_expired({ days => $days })->search({ login_attempts => { '!=' => -1 } }); + my $expired_patrons = Koha::Patrons->filter_by_dateexpiry({ days => $days })->search({ login_attempts => { '!=' => -1 } }); my $count = $expired_patrons->count; $expired_patrons->lock({ remove => 1 }) if $confirm; if( $verbose ) { diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 26e3366855..eabcf26dab 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -1798,16 +1798,16 @@ subtest '->set_password' => sub { }; $schema->storage->txn_begin; -subtest 'search_expired' => sub { +subtest 'filter_by_dateexpiry' => sub { plan tests => 3; - my $count1 = Koha::Patrons->search_expired({ days => 28 })->count; + my $count1 = Koha::Patrons->filter_by_dateexpiry({ days => 28 })->count; my $patron1 = $builder->build_object({ class => 'Koha::Patrons' }); $patron1->dateexpiry( dt_from_string->subtract(days => 27) )->store; - is( Koha::Patrons->search_expired({ days => 28 })->count, $count1, 'No more expired' ); + is( Koha::Patrons->filter_by_dateexpiry({ days => 28 })->count, $count1, 'No more expired' ); $patron1->dateexpiry( dt_from_string->subtract(days => 28) )->store; - is( Koha::Patrons->search_expired({ days => 28 })->count, $count1 + 1, 'One more expired' ); + is( Koha::Patrons->filter_by_dateexpiry({ days => 28 })->count, $count1 + 1, 'One more expired' ); $patron1->dateexpiry( dt_from_string->subtract(days => 29) )->store; - is( Koha::Patrons->search_expired({ days => 28 })->count, $count1 + 1, 'Same number again' ); + is( Koha::Patrons->filter_by_dateexpiry({ days => 28 })->count, $count1 + 1, 'Same number again' ); }; subtest 'search_unsubscribed' => sub { -- 2.11.0