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

(-)a/Koha/Patron.pm (+3 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->discard_changes;
328
                $self->update_lastseen('creation');
329
327
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
330
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
328
                    if C4::Context->preference("BorrowersLog");
331
                    if C4::Context->preference("BorrowersLog");
329
            } else {    #ModMember
332
            } 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 2012-2038 subtest 'test patron_consent' => sub { Link Here
2012
2012
2013
subtest 'update_lastseen tests' => sub {
2013
subtest 'update_lastseen tests' => sub {
2014
2014
2015
    plan tests => 24;
2015
    plan tests => 26;
2016
    $schema->storage->txn_begin;
2016
    $schema->storage->txn_begin;
2017
2017
2018
    my $cache = Koha::Caches->get_instance();
2019
2020
    t::lib::Mocks::mock_preference(
2021
        'TrackLastPatronActivityTriggers',
2022
        'creation,login,connection,check_in,check_out,renewal,hold,article'
2023
    );
2024
2018
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2025
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2019
    my $userid = $patron->userid;
2026
    my $userid = $patron->userid;
2020
2021
    $patron->lastseen(undef);
2027
    $patron->lastseen(undef);
2022
    $patron->store();
2028
    my $patron_info = $patron->unblessed;
2029
    delete $patron_info->{borrowernumber};
2030
    $patron->delete();
2031
    $patron = Koha::Patron->new($patron_info)->store();
2023
2032
2024
    my $cache     = Koha::Caches->get_instance();
2033
    my $now   = dt_from_string();
2025
    my $cache_key = "track_activity_" . $patron->borrowernumber;
2034
    my $today = $now->ymd();
2026
    $cache->clear_from_cache($cache_key);
2035
2036
    is(
2037
        dt_from_string( $patron->lastseen )->ymd(), $today,
2038
        'Patron should have last seen when newly created if requested'
2039
    );
2040
2041
    my $cache_key   = "track_activity_" . $patron->borrowernumber;
2042
    my $cache_value = $cache->get_from_cache($cache_key);
2043
    is( $cache_value, $today, "Cache was updated as expected" );
2044
2045
    $patron->delete();
2027
2046
2028
    t::lib::Mocks::mock_preference(
2047
    t::lib::Mocks::mock_preference(
2029
        'TrackLastPatronActivityTriggers',
2048
        'TrackLastPatronActivityTriggers',
2030
        'login,connection,check_in,check_out,renewal,hold,article'
2049
        'login,connection,check_in,check_out,renewal,hold,article'
2031
    );
2050
    );
2032
2051
2033
    is( $patron->lastseen, undef, 'Patron should have not last seen when newly created' );
2052
    $patron    = Koha::Patron->new($patron_info)->store();
2053
    $cache_key = "track_activity_" . $patron->borrowernumber;
2054
2055
    is( $patron->lastseen, undef, 'Patron should have not last seen when newly created if trigger not set' );
2034
2056
2035
    my $now = dt_from_string();
2057
    $now = dt_from_string();
2036
    Time::Fake->offset( $now->epoch );
2058
    Time::Fake->offset( $now->epoch );
2037
2059
2038
    $patron->update_lastseen('login');
2060
    $patron->update_lastseen('login');
2039
- 

Return to bug 23486