Bug 30133: Simplify code
This patch simplifies the code, and also fixes a problem with branchcode comparisson failing, highlighted when running the tests To test: 1. Apply the regression tests 2. Run: $ kshell k$ prove t/db_dependent/api/v1/items.t => FAIL: Tests fail. Notably: - Link header pagination is wrong - X-*Total-Count headers have two values (dupicated) 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
eb281a56cd
commit
eb5dbb4010
|
|
@ -113,7 +113,7 @@ sub pickup_locations {
|
|||
|
||||
return try {
|
||||
|
||||
my $ps_set = $item->pickup_locations( { patron => $patron } );
|
||||
my $pl_set = $item->pickup_locations( { patron => $patron } );
|
||||
|
||||
my @response = ();
|
||||
if ( C4::Context->preference('AllowHoldPolicyOverride') ) {
|
||||
|
|
@ -124,23 +124,19 @@ sub pickup_locations {
|
|||
@response = map {
|
||||
my $library = $_;
|
||||
$library->{needs_override} = (
|
||||
any { $_->{library_id} eq $library->{library_id} }
|
||||
@{$ps_set->as_list}
|
||||
any { $_->branchcode eq $library->{library_id} }
|
||||
@{ $pl_set->as_list }
|
||||
)
|
||||
? Mojo::JSON->false
|
||||
: Mojo::JSON->true;
|
||||
$library;
|
||||
} @{$libraries};
|
||||
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => \@response
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
||||
my $pickup_locations = $c->objects->search( $ps_set );
|
||||
|
||||
@response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations};
|
||||
my $pickup_locations = $c->objects->search($pl_set);
|
||||
@response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations};
|
||||
}
|
||||
|
||||
return $c->render(
|
||||
status => 200,
|
||||
|
|
|
|||
Loading…
Reference in New Issue