Bug 36277: Do not fetch the whole library list

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 14388b6478)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 4c56374272)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2024-03-14 14:06:28 +01:00 committed by Lucas Gass
parent 1371bbbfbb
commit 8e7d786871
1 changed files with 12 additions and 4 deletions

View File

@ -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 ) {