From 4c56374272bb458ee0497f9efd42c3db54723fcf Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 14 Mar 2024 14:06:28 +0100 Subject: [PATCH] Bug 36277: Do not fetch the whole library list Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Katrin Fischer (cherry picked from commit 14388b6478858e298a9f0de104d5e839bc8cb430) Signed-off-by: Fridolin Somers --- Koha/REST/V1/TransferLimits.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Koha/REST/V1/TransferLimits.pm b/Koha/REST/V1/TransferLimits.pm index 0d7b0eb472..83fa6c568d 100644 --- a/Koha/REST/V1/TransferLimits.pm +++ b/Koha/REST/V1/TransferLimits.pm @@ -128,10 +128,18 @@ sub batch_add { return try { my $params = $c->req->json; - my @libraries = Koha::Libraries->search->as_list; - - my @from_branches = $params->{from_library_id} ? $params->{from_library_id} : map { $_->id } @libraries; - my @to_branches = $params->{to_library_id} ? $params->{to_library_id} : map { $_->id } @libraries; + my ( @from_branches, @to_branches ); + if ( $params->{from_library_id} ) { + @from_branches = ( $params->{from_library_id} ); + } + if ( $params->{to_library_id} ) { + @to_branches = ( $params->{to_library_id} ); + } + unless ( $params->{from_library_id} && $params->{to_library_id} ) { + my @library_ids = Koha::Libraries->search->get_column('branchcode'); + @from_branches = @library_ids unless $params->{from_library_id}; + @to_branches = @library_ids unless $params->{to_library_id}; + } my @results; foreach my $from ( @from_branches ) { -- 2.39.5