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

(-)a/Koha/Patron.pm (+3 lines)
Lines 330-335 sub store { Link Here
330
330
331
                $self->add_enrolment_fee_if_needed(0);
331
                $self->add_enrolment_fee_if_needed(0);
332
332
333
                $self->discard_changes;
334
                $self->update_lastseen('creation');
335
333
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
336
                logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
334
                    if C4::Context->preference("BorrowersLog");
337
                    if C4::Context->preference("BorrowersLog");
335
            } else {    #ModMember
338
            } 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 2129-2155 subtest 'test patron_consent' => sub { Link Here
2129
2129
2130
subtest 'update_lastseen tests' => sub {
2130
subtest 'update_lastseen tests' => sub {
2131
2131
2132
    plan tests => 24;
2132
    plan tests => 26;
2133
    $schema->storage->txn_begin;
2133
    $schema->storage->txn_begin;
2134
2134
2135
    my $cache = Koha::Caches->get_instance();
2136
2137
    t::lib::Mocks::mock_preference(
2138
        'TrackLastPatronActivityTriggers',
2139
        'creation,login,connection,check_in,check_out,renewal,hold,article'
2140
    );
2141
2135
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2142
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2136
    my $userid = $patron->userid;
2143
    my $userid = $patron->userid;
2137
2138
    $patron->lastseen(undef);
2144
    $patron->lastseen(undef);
2139
    $patron->store();
2145
    my $patron_info = $patron->unblessed;
2146
    delete $patron_info->{borrowernumber};
2147
    $patron->delete();
2148
    $patron = Koha::Patron->new($patron_info)->store();
2140
2149
2141
    my $cache     = Koha::Caches->get_instance();
2150
    my $now   = dt_from_string();
2142
    my $cache_key = "track_activity_" . $patron->borrowernumber;
2151
    my $today = $now->ymd();
2143
    $cache->clear_from_cache($cache_key);
2152
2153
    is(
2154
        dt_from_string( $patron->lastseen )->ymd(), $today,
2155
        'Patron should have last seen when newly created if requested'
2156
    );
2157
2158
    my $cache_key   = "track_activity_" . $patron->borrowernumber;
2159
    my $cache_value = $cache->get_from_cache($cache_key);
2160
    is( $cache_value, $today, "Cache was updated as expected" );
2161
2162
    $patron->delete();
2144
2163
2145
    t::lib::Mocks::mock_preference(
2164
    t::lib::Mocks::mock_preference(
2146
        'TrackLastPatronActivityTriggers',
2165
        'TrackLastPatronActivityTriggers',
2147
        'login,connection,check_in,check_out,renewal,hold,article'
2166
        'login,connection,check_in,check_out,renewal,hold,article'
2148
    );
2167
    );
2149
2168
2150
    is( $patron->lastseen, undef, 'Patron should have not last seen when newly created' );
2169
    $patron    = Koha::Patron->new($patron_info)->store();
2170
    $cache_key = "track_activity_" . $patron->borrowernumber;
2171
2172
    is( $patron->lastseen, undef, 'Patron should have not last seen when newly created if trigger not set' );
2151
2173
2152
    my $now = dt_from_string();
2174
    $now = dt_from_string();
2153
    Time::Fake->offset( $now->epoch );
2175
    Time::Fake->offset( $now->epoch );
2154
2176
2155
    $patron->update_lastseen('login');
2177
    $patron->update_lastseen('login');
2156
- 

Return to bug 23486