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

(-)a/C4/Members.pm (+5 lines)
Lines 1802-1807 sub GetBorrowersToExpunge { Link Here
1802
    my $params = shift;
1802
    my $params = shift;
1803
    my $filterdate       = $params->{'not_borrowed_since'};
1803
    my $filterdate       = $params->{'not_borrowed_since'};
1804
    my $filterexpiry     = $params->{'expired_before'};
1804
    my $filterexpiry     = $params->{'expired_before'};
1805
    my $filterlastseen   = $params->{'last_seen'};
1805
    my $filtercategory   = $params->{'category_code'};
1806
    my $filtercategory   = $params->{'category_code'};
1806
    my $filterbranch     = $params->{'branchcode'} ||
1807
    my $filterbranch     = $params->{'branchcode'} ||
1807
                        ((C4::Context->preference('IndependentBranches')
1808
                        ((C4::Context->preference('IndependentBranches')
Lines 1842-1847 sub GetBorrowersToExpunge { Link Here
1842
        $query .= " AND dateexpiry < ? ";
1843
        $query .= " AND dateexpiry < ? ";
1843
        push( @query_params, $filterexpiry );
1844
        push( @query_params, $filterexpiry );
1844
    }
1845
    }
1846
    if ( $filterlastseen ) {
1847
        $query .= ' AND lastseen < ? ';
1848
        push @query_params, $filterlastseen;
1849
    }
1845
    if ( $filtercategory ) {
1850
    if ( $filtercategory ) {
1846
        $query .= " AND categorycode = ? ";
1851
        $query .= " AND categorycode = ? ";
1847
        push( @query_params, $filtercategory );
1852
        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 => 77;
20
use Test::More tests => 80;
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 365-373 is( scalar(@$patstodel),2,'Borrowers without issues deleted by expiration_date a Link Here
365
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
365
$patstodel = GetBorrowersToExpunge( {not_borrowed_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } );
366
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
366
is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date');
367
367
368
368
# Test GetBorrowersToExpunge and TrackLastPatronActivity
369
369
$dbh->do(q|UPDATE borrowers SET lastseen=NULL|);
370
370
$builder->build({ source => 'Borrower', value => { lastseen => '2016-01-01 01:01:01', guarantorid => undef } } );
371
$builder->build({ source => 'Borrower', value => { lastseen => '2016-02-02 02:02:02', guarantorid => undef } } );
372
$builder->build({ source => 'Borrower', value => { lastseen => '2016-03-03 03:03:03', guarantorid => undef } } );
373
$patstodel = GetBorrowersToExpunge( { last_seen => '1999-12-12' });
374
is( scalar @$patstodel, 0, 'TrackLastPatronActivity - 0 patrons must be deleted' );
375
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' });
376
is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' );
377
$patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' });
378
is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' );
371
379
372
# Regression tests for BZ13502
380
# Regression tests for BZ13502
373
## Remove all entries with userid='' (should be only 1 max)
381
## Remove all entries with userid='' (should be only 1 max)
374
- 

Return to bug 16276