Bugzilla – Attachment 164898 Details for
Bug 36605
TrackLastPatronActivity for SIP should track both patron status and patron information requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36605: Add update_lastseen to handle_patron_status for SIP
Bug-36605-Add-updatelastseen-to-handlepatronstatus.patch (text/plain), 4.75 KB, created by
Martin Renvoize (ashimema)
on 2024-04-16 06:29:32 UTC
(
hide
)
Description:
Bug 36605: Add update_lastseen to handle_patron_status for SIP
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-16 06:29:32 UTC
Size:
4.75 KB
patch
obsolete
>From fe757a145e17095b2468eab2ce8c97340dc59411 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 16 Apr 2024 03:50:21 +0000 >Subject: [PATCH] Bug 36605: Add update_lastseen to handle_patron_status for > SIP > >This patch extends the TrackLastPatronActivity trigger to cover SIP status messages as well. >Other SIP messages like Checkin/Checkout should be covered by those values in system preference, so >should not need adjustment. > >To test: >prove -v t/db_dependent/SIP/Message.t > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/SIP/Sip/MsgType.pm | 4 +++ > t/db_dependent/SIP/Message.t | 70 ++++++++++++++++++++++++++++++++++-- > 2 files changed, 72 insertions(+), 2 deletions(-) > >diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm >index 3c52df30f47..4fcd4e486a0 100644 >--- a/C4/SIP/Sip/MsgType.pm >+++ b/C4/SIP/Sip/MsgType.pm >@@ -504,6 +504,10 @@ sub handle_patron_status { > > $ils->check_inst_id( $fields->{ (FID_INST_ID) }, "handle_patron_status" ); > $patron = $ils->find_patron( $fields->{ (FID_PATRON_ID) } ); >+ if ( C4::Context->preference('TrackLastPatronActivityTriggers') ) { >+ my $koha_patron = Koha::Patrons->find($patron->{borrowernumber}); >+ $koha_patron->update_lastseen('connection'); >+ } > $resp = build_patron_status( $patron, $lang, $fields, $server ); > $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} ); > return (PATRON_STATUS_REQ); >diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t >index c6c71bd2944..b7c01b4f711 100755 >--- a/t/db_dependent/SIP/Message.t >+++ b/t/db_dependent/SIP/Message.t >@@ -21,7 +21,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 18; >+use Test::More tests => 19; > use Test::Exception; > use Test::MockObject; > use Test::MockModule; >@@ -196,7 +196,7 @@ subtest 'hold_patron_name() tests' => sub { > $schema->storage->txn_rollback; > }; > >-subtest 'Lastseen response' => sub { >+subtest 'Lastseen response patron info' => sub { > > plan tests => 6; > >@@ -342,6 +342,72 @@ subtest "Test patron_status_string" => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'Lastseen response patron status' => sub { >+ >+ plan tests => 6; >+ >+ my $schema = Koha::Database->new->schema; >+ $schema->storage->txn_begin; >+ >+ my $builder = t::lib::TestBuilder->new(); >+ my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my ( $response, $findpatron ); >+ my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); >+ my $seen_patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { >+ lastseen => '2001-01-01', >+ password => hash_password(PATRON_PW), >+ branchcode => $branchcode, >+ }, >+ } >+ ); >+ my $cardnum = $seen_patron->{cardnumber}; >+ my $sip_patron = C4::SIP::ILS::Patron->new($cardnum); >+ $findpatron = $sip_patron; >+ >+ my $siprequest = >+ PATRON_STATUS_REQ >+ . 'engYYYYMMDDZZZZHHMMSS' >+ . FID_INST_ID >+ . $branchcode . '|' >+ . FID_PATRON_ID >+ . $cardnum . '|' >+ . FID_PATRON_PWD >+ . PATRON_PW . '|'; >+ my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); >+ >+ my $server = { ils => $mocks->{ils} }; >+ undef $response; >+ >+ t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', '' ); >+ $msg->handle_patron_status($server); >+ >+ isnt( $response, undef, 'At least we got a response.' ); >+ my $respcode = substr( $response, 0, 2 ); >+ is( $respcode, PATRON_STATUS_RESP, 'Response code fine' ); >+ $seen_patron = Koha::Patrons->find( { cardnumber => $seen_patron->{cardnumber} } ); >+ is( >+ output_pref( { str => $seen_patron->lastseen(), dateonly => 1 } ), >+ output_pref( { str => '2001-01-01', dateonly => 1 } ), 'Last seen not updated if not tracking patrons' >+ ); >+ undef $response; >+ t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'connection' ); >+ $msg->handle_patron_status($server); >+ >+ isnt( $response, undef, 'At least we got a response.' ); >+ $respcode = substr( $response, 0, 2 ); >+ is( $respcode, PATRON_STATUS_RESP, 'Response code fine' ); >+ $seen_patron = Koha::Patrons->find( { cardnumber => $seen_patron->cardnumber() } ); >+ is( >+ output_pref( { str => $seen_patron->lastseen(), dateonly => 1 } ), >+ output_pref( { dt => dt_from_string(), dateonly => 1 } ), 'Last seen updated if tracking patrons' >+ ); >+ $schema->storage->txn_rollback; >+ >+}; >+ > subtest "Test build_additional_item_fields_string" => sub { > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >-- >2.44.0
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 36605
:
164897
| 164898 |
165921