View | Details | Raw Unified | Return to bug 21549
Collapse All | Expand All

(-)a/Koha/Patrons.pm (-3 / +3 lines)
Lines 233-247 sub delete { Link Here
233
    return $patrons_deleted;
233
    return $patrons_deleted;
234
}
234
}
235
235
236
=head3 search_expired
236
=head3 filter_by_dateexpiry
237
237
238
    Koha::Patrons->search_expired{{ days => $x });
238
    Koha::Patrons->filter_by_dateexpiry{{ days => $x });
239
239
240
    Returns set of Koha patron objects expired $x days.
240
    Returns set of Koha patron objects expired $x days.
241
241
242
=cut
242
=cut
243
243
244
sub search_expired {
244
sub filter_by_dateexpiry {
245
    my ( $class, $params ) = @_;
245
    my ( $class, $params ) = @_;
246
    my $days = $params->{days} || 0;
246
    my $days = $params->{days} || 0;
247
    my $parser = Koha::Database->new->schema->storage->datetime_parser;
247
    my $parser = Koha::Database->new->schema->storage->datetime_parser;
(-)a/misc/cronjobs/cleanup_database.pl (-1 / +1 lines)
Lines 404-410 if($allDebarments) { Link Here
404
my $days = C4::Context->preference('LockExpiredDelay');
404
my $days = C4::Context->preference('LockExpiredDelay');
405
if( defined $days && $days ne q{} ) {
405
if( defined $days && $days ne q{} ) {
406
    say "Start locking expired patrons" if $verbose;
406
    say "Start locking expired patrons" if $verbose;
407
    my $expired_patrons = Koha::Patrons->search_expired({ days => $days })->search({ login_attempts => { '!=' => -1 } });
407
    my $expired_patrons = Koha::Patrons->filter_by_dateexpiry({ days => $days })->search({ login_attempts => { '!=' => -1 } });
408
    my $count = $expired_patrons->count;
408
    my $count = $expired_patrons->count;
409
    $expired_patrons->lock({ remove => 1 }) if $confirm;
409
    $expired_patrons->lock({ remove => 1 }) if $confirm;
410
    if( $verbose ) {
410
    if( $verbose ) {
(-)a/t/db_dependent/Koha/Patrons.t (-6 / +5 lines)
Lines 1798-1813 subtest '->set_password' => sub { Link Here
1798
};
1798
};
1799
1799
1800
$schema->storage->txn_begin;
1800
$schema->storage->txn_begin;
1801
subtest 'search_expired' => sub {
1801
subtest 'filter_by_dateexpiry' => sub {
1802
    plan tests => 3;
1802
    plan tests => 3;
1803
    my $count1 = Koha::Patrons->search_expired({ days => 28 })->count;
1803
    my $count1 = Koha::Patrons->filter_by_dateexpiry({ days => 28 })->count;
1804
    my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
1804
    my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
1805
    $patron1->dateexpiry( dt_from_string->subtract(days => 27) )->store;
1805
    $patron1->dateexpiry( dt_from_string->subtract(days => 27) )->store;
1806
    is( Koha::Patrons->search_expired({ days => 28 })->count, $count1, 'No more expired' );
1806
    is( Koha::Patrons->filter_by_dateexpiry({ days => 28 })->count, $count1, 'No more expired' );
1807
    $patron1->dateexpiry( dt_from_string->subtract(days => 28) )->store;
1807
    $patron1->dateexpiry( dt_from_string->subtract(days => 28) )->store;
1808
    is( Koha::Patrons->search_expired({ days => 28 })->count, $count1 + 1, 'One more expired' );
1808
    is( Koha::Patrons->filter_by_dateexpiry({ days => 28 })->count, $count1 + 1, 'One more expired' );
1809
    $patron1->dateexpiry( dt_from_string->subtract(days => 29) )->store;
1809
    $patron1->dateexpiry( dt_from_string->subtract(days => 29) )->store;
1810
    is( Koha::Patrons->search_expired({ days => 28 })->count, $count1 + 1, 'Same number again' );
1810
    is( Koha::Patrons->filter_by_dateexpiry({ days => 28 })->count, $count1 + 1, 'Same number again' );
1811
};
1811
};
1812
1812
1813
subtest 'search_unsubscribed' => sub {
1813
subtest 'search_unsubscribed' => sub {
1814
- 

Return to bug 21549