Bug 26993: (follow-up) Rename last_returned_by_all as last_borrowers

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Lucas Gass 2025-10-06 16:53:42 +00:00
parent cf018a0bf4
commit 9d4b4efffd
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
3 changed files with 14 additions and 14 deletions

View File

@ -927,13 +927,13 @@ sub get_transfers {
return Koha::Item::Transfers->_new_from_dbic($transfers_rs);
}
=head3 last_returned_by_all
=head3 last_borrowers
Returns all patrons who have returned this item, ordered by most recent first.
=cut
sub last_returned_by_all {
sub last_borrowers {
my ($self) = @_;
my $max_stored_borrowers = C4::Context->preference('StoreLastBorrower') || 0;
@ -977,7 +977,7 @@ sub last_returned_by {
# If StoreLastBorrower is 0 or disabled, bail without storing anything. Also delete any remaining rows from the table.
if ( $max_stored_borrowers == 0 ) {
$self->last_returned_by_all->delete;
$self->last_borrowers->delete;
return $self;
}

View File

@ -495,7 +495,7 @@
</li>
[% IF Koha.Preference('StoreLastBorrower') && Koha.Preference('StoreLastBorrower') > 0 %]
[% SET all_borrowers = ITEM_DAT.object.last_returned_by_all %]
[% SET all_borrowers = ITEM_DAT.object.last_borrowers %]
[% IF all_borrowers.count > 0 %]
<li>
<span class="label">Last returned by:</span>

View File

@ -150,10 +150,10 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
my $item = $builder->build_sample_item;
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } );
# Test last_returned_by_all with no borrowers
# Test last_borrowers with no borrowers
t::lib::Mocks::mock_preference( 'StoreLastBorrower', '3' );
my $borrowers = $item->last_returned_by_all();
is( $borrowers->count, 0, 'last_returned_by_all returns empty set when no borrowers stored' );
my $borrowers = $item->last_borrowers();
is( $borrowers->count, 0, 'last_borrowers returns empty set when no borrowers stored' );
# Add 3 borrowers for testing, checkout/check in
my @patrons;
@ -182,8 +182,8 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
$item = $item->get_from_storage;
# Test last_returned_by_all returns all borrowers
$borrowers = $item->last_returned_by_all();
# Test last_borrowers returns all borrowers
$borrowers = $item->last_borrowers();
is( $borrowers->count, 3, 'Correctly returns 3 borrowers' );
# Test ordering
@ -217,7 +217,7 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
}
$item = $item->get_from_storage;
$borrowers = $item->last_returned_by_all();
$borrowers = $item->last_borrowers();
is(
$borrowers->count, 3,
'We only retain 3 borrowers when the sys pref is set to 3, even though there are 5 checkouts/checkins'
@ -251,7 +251,7 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
);
$item = $item->get_from_storage;
$borrowers = $item->last_returned_by_all();
$borrowers = $item->last_borrowers();
is( $borrowers->count, 2, 'StoreLastBorrower was reduced to 2, we should now only keep 2 in the table' );
@borrowers_array = $borrowers->as_list;
is(
@ -286,8 +286,8 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
);
$item = $item->get_from_storage;
$borrowers = $item->last_returned_by_all();
is( $borrowers->count, 0, 'last_returned_by_all respects preference value 0' );
$borrowers = $item->last_borrowers();
is( $borrowers->count, 0, 'last_borrowers respects preference value 0' );
my $cleanup_patron = $builder->build(
{
@ -312,7 +312,7 @@ subtest 'Test StoreLastBorrower with multiple borrowers' => sub {
);
$item = $item->get_from_storage;
$borrowers = $item->last_returned_by_all();
$borrowers = $item->last_borrowers();
is( $borrowers->count, 0, 'All entries cleared when preference is 0' );
is( $item->last_returned_by, undef, 'last_returned_by returns undef when no records' );