Bugzilla – Attachment 171829 Details for
Bug 23486
TrackLastPatronActivityTriggers should have an option for patron creation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23486: Add creation to TrackLasPatronActivity triggers
Bug-23486-Add-creation-to-TrackLasPatronActivity-t.patch (text/plain), 4.45 KB, created by
Nick Clemens (kidclamp)
on 2024-09-20 12:45:09 UTC
(
hide
)
Description:
Bug 23486: Add creation to TrackLasPatronActivity triggers
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-09-20 12:45:09 UTC
Size:
4.45 KB
patch
obsolete
>From fb869faa897d11812b338d894b24432388778338 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 20 Sep 2024 12:38:42 +0000 >Subject: [PATCH] Bug 23486: Add creation to TrackLasPatronActivity triggers > >Some libraries would like to update the last seen when a patron is created to avoid NULL >values and ensure new users are marked as 'active' > >To test: >1 - Apply patch >2 - Create a new patron, confirm their lastseen date is null > SELECT lastseen FROM borrowers WHERE cardnumber={their cardnumber} >3 - Update preference 'TrackLastPatronActivity' to include 'Patron creation' >4 - Create a second patron, confirm their lastseen is set >5 - Update preference 'TrackLastPatronActivity' to include 'Checking out an item' >6 - Checkout an item to the second patron >7 - Confirm their lastseen is not updated (We only update once per day) >--- > Koha/Patron.pm | 2 + > .../en/modules/admin/preferences/patrons.pref | 1 + > t/db_dependent/Koha/Patron.t | 38 +++++++++++++++---- > 3 files changed, 33 insertions(+), 8 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index fcbd6cd71ed..0b8203e0346 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -324,6 +324,8 @@ sub store { > > $self->add_enrolment_fee_if_needed(0); > >+ $self->update_lastseen('creation'); >+ > logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" ) > if C4::Context->preference("BorrowersLog"); > } else { #ModMember >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 4376132e57e..6e82da7d277 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -102,6 +102,7 @@ Patrons: > - 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. > - pref: TrackLastPatronActivityTriggers > multiple: >+ creation: "Patron creation" > login: "Logging in" > connection: "Connecting to Koha via SIP or ILSDI" > check_out: "Checking out an item" >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 970235ecc55..2ef841759d5 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -1975,27 +1975,49 @@ subtest 'test patron_consent' => sub { > > subtest 'update_lastseen tests' => sub { > >- plan tests => 24; >+ plan tests => 26; > $schema->storage->txn_begin; > >+ my $cache = Koha::Caches->get_instance(); >+ >+ t::lib::Mocks::mock_preference( >+ 'TrackLastPatronActivityTriggers', >+ 'creation,login,connection,check_in,check_out,renewal,hold,article' >+ ); >+ > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $userid = $patron->userid; >- > $patron->lastseen(undef); >- $patron->store(); >+ my $patron_info = $patron->unblessed; >+ delete $patron_info->{borrowernumber}; >+ $patron->delete(); >+ $patron = Koha::Patron->new($patron_info)->store(); > >- my $cache = Koha::Caches->get_instance(); >- my $cache_key = "track_activity_" . $patron->borrowernumber; >- $cache->clear_from_cache($cache_key); >+ my $now = dt_from_string(); >+ my $today = $now->ymd(); >+ >+ is( >+ dt_from_string( $patron->lastseen )->ymd(), $today, >+ 'Patron should have last seen when newly created if requested' >+ ); >+ >+ my $cache_key = "track_activity_" . $patron->borrowernumber; >+ my $cache_value = $cache->get_from_cache($cache_key); >+ is( $cache_value, $today, "Cache was updated as expected" ); >+ >+ $patron->delete(); > > t::lib::Mocks::mock_preference( > 'TrackLastPatronActivityTriggers', > 'login,connection,check_in,check_out,renewal,hold,article' > ); > >- is( $patron->lastseen, undef, 'Patron should have not last seen when newly created' ); >+ $patron = Koha::Patron->new($patron_info)->store(); >+ $cache_key = "track_activity_" . $patron->borrowernumber; >+ >+ is( $patron->lastseen, undef, 'Patron should have not last seen when newly created if trigger not set' ); > >- my $now = dt_from_string(); >+ $now = dt_from_string(); > Time::Fake->offset( $now->epoch ); > > $patron->update_lastseen('login'); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23486
:
131657
|
131658
|
132222
|
134540
|
134547
|
134549
|
134550
|
134551
|
134963
|
134964
|
148780
|
148781
|
149273
|
149274
|
150119
|
150120
|
171829
|
172820
|
172927
|
172928
|
174080
|
174081