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

(-)a/C4/Members.pm (+5 lines)
Lines 1754-1759 sub GetBorrowersToExpunge { Link Here
1754
    my $params = shift;
1754
    my $params = shift;
1755
    my $filterdate       = $params->{'not_borrowed_since'};
1755
    my $filterdate       = $params->{'not_borrowed_since'};
1756
    my $filterexpiry     = $params->{'expired_before'};
1756
    my $filterexpiry     = $params->{'expired_before'};
1757
    my $filterlastseen   = $params->{'last_seen'};
1757
    my $filtercategory   = $params->{'category_code'};
1758
    my $filtercategory   = $params->{'category_code'};
1758
    my $filterbranch     = $params->{'branchcode'} ||
1759
    my $filterbranch     = $params->{'branchcode'} ||
1759
                        ((C4::Context->preference('IndependentBranches')
1760
                        ((C4::Context->preference('IndependentBranches')
Lines 1794-1799 sub GetBorrowersToExpunge { Link Here
1794
        $query .= " AND dateexpiry < ? ";
1795
        $query .= " AND dateexpiry < ? ";
1795
        push( @query_params, $filterexpiry );
1796
        push( @query_params, $filterexpiry );
1796
    }
1797
    }
1798
    if ( $filterlastseen ) {
1799
        $query .= ' AND lastseen < ? ';
1800
        push @query_params, $filterlastseen;
1801
    }
1797
    if ( $filtercategory ) {
1802
    if ( $filtercategory ) {
1798
        $query .= " AND categorycode = ? ";
1803
        $query .= " AND categorycode = ? ";
1799
        push( @query_params, $filtercategory );
1804
        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 => 76;
20
use Test::More tests => 79;
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 353-361 is( scalar(@$patstodel),2,'Borrowers without issues deleted by expiration_date a Link Here
353
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
353
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
354
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
354
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
355
355
356
356
# Test GetBorrowersToExpunge and TrackLastPatronActivity
357
357
$dbh->do(q|UPDATE borrowers SET lastseen=NULL|);
358
358
$builder->build({ source => 'Borrower', value => { lastseen => '2016-01-01 01:01:01', guarantorid => undef } } );
359
$builder->build({ source => 'Borrower', value => { lastseen => '2016-02-02 02:02:02', guarantorid => undef } } );
360
$builder->build({ source => 'Borrower', value => { lastseen => '2016-03-03 03:03:03', guarantorid => undef } } );
361
$patstodel = GetBorrowersToExpunge( { last_seen => '1999-12-12' });
362
is( scalar @$patstodel, 0, 'TrackLastPatronActivity - 0 patrons must be deleted' );
363
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' });
364
is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' );
365
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' });
366
is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' );
359
367
360
# Regression tests for BZ13502
368
# Regression tests for BZ13502
361
## Remove all entries with userid='' (should be only 1 max)
369
## Remove all entries with userid='' (should be only 1 max)
362
- 

Return to bug 16276