Bugzilla – Attachment 193219 Details for
Bug 23269
Long hold queues are slowing the service
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23269: (follow-up) Rename to item_level_holds_count and add tests
0003-Bug-23269-follow-up-Rename-to-item_level_holds_count.patch (text/plain), 8.14 KB, created by
Johanna Räisä
on 2026-02-16 13:20:30 UTC
(
hide
)
Description:
Bug 23269: (follow-up) Rename to item_level_holds_count and add tests
Filename:
MIME Type:
Creator:
Johanna Räisä
Created:
2026-02-16 13:20:30 UTC
Size:
8.14 KB
patch
obsolete
>From f21e1cd9b4fbb892b7889725257194e871058878 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Johanna=20R=C3=A4is=C3=A4?= <johanna.raisa@gmail.com> >Date: Mon, 16 Feb 2026 12:24:43 +0200 >Subject: [PATCH 3/3] Bug 23269: (follow-up) Rename to item_level_holds_count > and add tests > >Test plan: >1. prove t/db_dependent/Koha/Holds.t > >Sponsored-by: Koha-Suomi Oy >--- > Koha/Hold.pm | 4 +- > api/v1/swagger/definitions/hold.yaml | 4 +- > api/v1/swagger/paths/holds.yaml | 2 +- > koha-tmpl/intranet-tmpl/prog/js/holds.js | 6 +- > t/db_dependent/Koha/Holds.t | 84 ++++++++++++++++++++++-- > 5 files changed, 87 insertions(+), 13 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 91269aa535..d4a022e3ac 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -783,13 +783,13 @@ sub is_suspended { > return $self->suspend(); > } > >-=head3 item_level_holds >+=head3 item_level_holds_count > > Returns the number (count) of item-level holds for this hold's biblionumber and patron > > =cut > >-sub item_level_holds { >+sub item_level_holds_count { > my ($self) = @_; > > return Koha::Holds->search( >diff --git a/api/v1/swagger/definitions/hold.yaml b/api/v1/swagger/definitions/hold.yaml >index c1c6363ae4..a466e4eeec 100644 >--- a/api/v1/swagger/definitions/hold.yaml >+++ b/api/v1/swagger/definitions/hold.yaml >@@ -114,8 +114,8 @@ properties: > item_level: > type: boolean > description: If the hold is placed at item level >- item_level_holds: >- type: >+ item_level_holds_count: >+ type: > - integer > - "null" > description: Count of item level holds for this bibliographic record >diff --git a/api/v1/swagger/paths/holds.yaml b/api/v1/swagger/paths/holds.yaml >index 71474e1218..782f392e15 100644 >--- a/api/v1/swagger/paths/holds.yaml >+++ b/api/v1/swagger/paths/holds.yaml >@@ -109,7 +109,7 @@ > - item > - patron > - item_group >- - item_level_holds >+ - item_level_holds_count > collectionFormat: csv > produces: > - application/json >diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js >index fe1427d5c7..653b6879c9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js >@@ -1314,7 +1314,7 @@ async function load_patron_holds_table(biblio_id, split_data) { > ajax: { > url: url, > }, >- embed: ["patron", "item", "item_group", "item_level_holds"], >+ embed: ["patron", "item", "item_group", "item_level_holds_count"], > columnDefs: [ > { > targets: [2, 3], >@@ -1347,7 +1347,7 @@ async function load_patron_holds_table(biblio_id, split_data) { > '" data-hold-group-id="' + > row.hold_group_id + > '" data-item_level_hold="' + >- row.item_level_holds + >+ row.item_level_holds_count + > '" data-waiting="' + > (row.status === "W" ? "1" : "") + > '" data-intransit="' + >@@ -1646,7 +1646,7 @@ async function load_patron_holds_table(biblio_id, split_data) { > row.item.external_id || __("No barcode"); > const itemLink = `<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=${row.biblio_id}&itemnumber=${row.item_id}">${barcode.escapeHtml ? barcode.escapeHtml() : barcode}</a>`; > >- if (row.item_level_holds >= 2) { >+ if (row.item_level_holds_count >= 2) { > return `${__("Only item")} ${itemLink}${group_hold_message}`; > } > >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index d81fc342e1..6780ab0693 100755 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -20,7 +20,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 14; >+use Test::More tests => 15; > use Test::Warn; > > use C4::Circulation qw( AddIssue ); >@@ -466,8 +466,7 @@ subtest 'cancel' => sub { > my $reserve_id = C4::Reserves::AddReserve($hold_info); > Koha::Holds->find($reserve_id)->cancel; > my $number_of_logs = >- $schema->resultset('ActionLog') >- ->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } ) >+ $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } ) > ->count; > is( $number_of_logs, 0, 'Without HoldsLog, Koha::Hold->cancel should not have logged' ); > >@@ -475,8 +474,7 @@ subtest 'cancel' => sub { > $reserve_id = C4::Reserves::AddReserve($hold_info); > Koha::Holds->find($reserve_id)->cancel; > $number_of_logs = >- $schema->resultset('ActionLog') >- ->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } ) >+ $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'CANCEL', object => $reserve_id } ) > ->count; > is( $number_of_logs, 1, 'With HoldsLog, Koha::Hold->cancel should have logged' ); > }; >@@ -1296,3 +1294,79 @@ subtest 'processing() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'item_level_holds_count() tests' => sub { >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $other_patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ # Create a biblio-level hold for the patron >+ my $biblio_hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ itemnumber => undef, >+ item_level_hold => 0, >+ } >+ } >+ ); >+ >+ is( $biblio_hold->item_level_holds_count, 0, 'No item-level holds yet for this patron/biblio' ); >+ >+ # Create first item-level hold for the patron >+ my $item_hold_1 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item_1->itemnumber, >+ item_level_hold => 1, >+ } >+ } >+ ); >+ >+ is( $item_hold_1->item_level_holds_count, 1, 'One item-level hold for this patron/biblio' ); >+ is( $biblio_hold->item_level_holds_count, 1, 'Biblio-level hold also sees the item-level hold count' ); >+ >+ # Create second item-level hold for the patron >+ my $item_hold_2 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item_2->itemnumber, >+ item_level_hold => 1, >+ } >+ } >+ ); >+ >+ is( $item_hold_2->item_level_holds_count, 2, 'Two item-level holds for this patron/biblio' ); >+ >+ # Create item-level hold for different patron - should not be counted >+ my $other_patron_hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $other_patron->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item_1->itemnumber, >+ item_level_hold => 1, >+ } >+ } >+ ); >+ >+ is( $item_hold_1->item_level_holds_count, 2, 'Still two item-level holds for original patron' ); >+ is( $other_patron_hold->item_level_holds_count, 1, 'Only one item-level hold for other patron' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.34.1 >
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 23269
:
173770
|
176705
|
177151
|
181244
|
181247
|
182728
|
182729
|
182730
|
182754
|
182755
|
182756
|
182757
|
191638
|
191669
|
191670
|
192821
|
192849
|
192850
|
192851
|
192939
|
192940
|
192941
|
192942
|
192943
|
193100
|
193101
|
193102
|
193103
|
193104
|
193198
|
193199
|
193200
|
193201
| 193219 |
193336