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

(-)a/Koha/Patron.pm (+2 lines)
Lines 324-329 sub store { Link Here
324
324
325
                $self->add_enrolment_fee_if_needed(0);
325
                $self->add_enrolment_fee_if_needed(0);
326
326
327
                $self->update_lastseen('creation');
328
327
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
329
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
328
                    if C4::Context->preference("BorrowersLog");
330
                    if C4::Context->preference("BorrowersLog");
329
            } else {    #ModMember
331
            } else {    #ModMember
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+1 lines)
Lines 102-107 Patrons: Link Here
102
         - Select which patron activities should be tracked to signify patron activity. Each time that one of these activities occurs, borrowers.lastseen will update with the current date and time.
102
         - Select which patron activities should be tracked to signify patron activity. Each time that one of these activities occurs, borrowers.lastseen will update with the current date and time.
103
         - pref: TrackLastPatronActivityTriggers
103
         - pref: TrackLastPatronActivityTriggers
104
           multiple:
104
           multiple:
105
               creation: "Patron creation"
105
               login: "Logging in"
106
               login: "Logging in"
106
               connection: "Connecting to Koha via SIP or ILSDI"
107
               connection: "Connecting to Koha via SIP or ILSDI"
107
               check_out: "Checking out an item"
108
               check_out: "Checking out an item"
(-)a/t/db_dependent/Koha/Patron.t (-9 / +30 lines)
Lines 1975-2001 subtest 'test patron_consent' => sub { Link Here
1975
1975
1976
subtest 'update_lastseen tests' => sub {
1976
subtest 'update_lastseen tests' => sub {
1977
1977
1978
    plan tests => 24;
1978
    plan tests => 26;
1979
    $schema->storage->txn_begin;
1979
    $schema->storage->txn_begin;
1980
1980
1981
    my $cache = Koha::Caches->get_instance();
1982
1983
    t::lib::Mocks::mock_preference(
1984
        'TrackLastPatronActivityTriggers',
1985
        'creation,login,connection,check_in,check_out,renewal,hold,article'
1986
    );
1987
1981
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1988
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1982
    my $userid = $patron->userid;
1989
    my $userid = $patron->userid;
1983
1984
    $patron->lastseen(undef);
1990
    $patron->lastseen(undef);
1985
    $patron->store();
1991
    my $patron_info = $patron->unblessed;
1992
    delete $patron_info->{borrowernumber};
1993
    $patron->delete();
1994
    $patron = Koha::Patron->new($patron_info)->store();
1986
1995
1987
    my $cache     = Koha::Caches->get_instance();
1996
    my $now   = dt_from_string();
1988
    my $cache_key = "track_activity_" . $patron->borrowernumber;
1997
    my $today = $now->ymd();
1989
    $cache->clear_from_cache($cache_key);
1998
1999
    is(
2000
        dt_from_string( $patron->lastseen )->ymd(), $today,
2001
        'Patron should have last seen when newly created if requested'
2002
    );
2003
2004
    my $cache_key   = "track_activity_" . $patron->borrowernumber;
2005
    my $cache_value = $cache->get_from_cache($cache_key);
2006
    is( $cache_value, $today, "Cache was updated as expected" );
2007
2008
    $patron->delete();
1990
2009
1991
    t::lib::Mocks::mock_preference(
2010
    t::lib::Mocks::mock_preference(
1992
        'TrackLastPatronActivityTriggers',
2011
        'TrackLastPatronActivityTriggers',
1993
        'login,connection,check_in,check_out,renewal,hold,article'
2012
        'login,connection,check_in,check_out,renewal,hold,article'
1994
    );
2013
    );
1995
2014
1996
    is( $patron->lastseen, undef, 'Patron should have not last seen when newly created' );
2015
    $patron    = Koha::Patron->new($patron_info)->store();
2016
    $cache_key = "track_activity_" . $patron->borrowernumber;
2017
2018
    is( $patron->lastseen, undef, 'Patron should have not last seen when newly created if trigger not set' );
1997
2019
1998
    my $now = dt_from_string();
2020
    $now = dt_from_string();
1999
    Time::Fake->offset( $now->epoch );
2021
    Time::Fake->offset( $now->epoch );
2000
2022
2001
    $patron->update_lastseen('login');
2023
    $patron->update_lastseen('login');
2002
- 

Return to bug 23486