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

(-)a/C4/Members.pm (+5 lines)
Lines 1677-1682 sub GetBorrowersToExpunge { Link Here
1677
    my $params = shift;
1677
    my $params = shift;
1678
    my $filterdate       = $params->{'not_borrowed_since'};
1678
    my $filterdate       = $params->{'not_borrowed_since'};
1679
    my $filterexpiry     = $params->{'expired_before'};
1679
    my $filterexpiry     = $params->{'expired_before'};
1680
    my $filterlastseen   = $params->{'last_seen'};
1680
    my $filtercategory   = $params->{'category_code'};
1681
    my $filtercategory   = $params->{'category_code'};
1681
    my $filterbranch     = $params->{'branchcode'} ||
1682
    my $filterbranch     = $params->{'branchcode'} ||
1682
                        ((C4::Context->preference('IndependentBranches')
1683
                        ((C4::Context->preference('IndependentBranches')
Lines 1717-1722 sub GetBorrowersToExpunge { Link Here
1717
        $query .= " AND dateexpiry < ? ";
1718
        $query .= " AND dateexpiry < ? ";
1718
        push( @query_params, $filterexpiry );
1719
        push( @query_params, $filterexpiry );
1719
    }
1720
    }
1721
    if ( $filterlastseen ) {
1722
        $query .= ' AND lastseen < ? ';
1723
        push @query_params, $filterlastseen;
1724
    }
1720
    if ( $filtercategory ) {
1725
    if ( $filtercategory ) {
1721
        $query .= " AND categorycode = ? ";
1726
        $query .= " AND categorycode = ? ";
1722
        push( @query_params, $filtercategory );
1727
        push( @query_params, $filtercategory );
(-)a/t/db_dependent/Members.t (-5 / +12 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 79;
20
use Test::More tests => 81;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Data::Dumper;
22
use Data::Dumper;
23
use C4::Context;
23
use C4::Context;
Lines 376-384 is( scalar(@$patstodel),2,'Borrowers without issues deleted by expiration_date a Link Here
376
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
376
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
377
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
377
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
378
378
379
379
# Test GetBorrowersToExpunge and TrackLastPatronActivity
380
380
$dbh->do(q|UPDATE borrowers SET lastseen=NULL|);
381
381
$builder->build({ source => 'Borrower', value => { lastseen => '2016-01-01 01:01:01', guarantorid => undef } } );
382
$builder->build({ source => 'Borrower', value => { lastseen => '2016-02-02 02:02:02', guarantorid => undef } } );
383
$builder->build({ source => 'Borrower', value => { lastseen => '2016-03-03 03:03:03', guarantorid => undef } } );
384
$patstodel = GetBorrowersToExpunge( { last_seen => '1999-12-12' });
385
is( scalar @$patstodel, 0, 'TrackLastPatronActivity - 0 patrons must be deleted' );
386
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' });
387
is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' );
388
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' });
389
is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' );
382
390
383
# Regression tests for BZ13502
391
# Regression tests for BZ13502
384
## Remove all entries with userid='' (should be only 1 max)
392
## Remove all entries with userid='' (should be only 1 max)
385
- 

Return to bug 16276