Bug 9367: Followup: Code optimization: CheckReserves is too often called
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
This commit is contained in:
parent
fad1f44d42
commit
37b6ac0b14
|
|
@ -2473,18 +2473,17 @@ sub CanBookBeRenewed {
|
|||
|
||||
$sthcount->execute( $borrowernumber, $itemnumber );
|
||||
if ( my $data1 = $sthcount->fetchrow_hashref ) {
|
||||
|
||||
if ( ( $data1->{renewalsallowed} && $data1->{renewalsallowed} > $data1->{renewals} ) || $override_limit ) {
|
||||
$renewokay = 1;
|
||||
}
|
||||
else {
|
||||
$error="too_many";
|
||||
}
|
||||
|
||||
$error = "too_many";
|
||||
}
|
||||
|
||||
my $resstatus = C4::Reserves::GetReserveStatus($itemnumber);
|
||||
if ( $resstatus eq "Waiting" or $resstatus eq "Reserved" ) {
|
||||
$renewokay = 0;
|
||||
$error->{message} = "on_reserve";
|
||||
$error = "on_reserve";
|
||||
}
|
||||
}
|
||||
return ($renewokay,$error);
|
||||
|
|
|
|||
|
|
@ -735,26 +735,33 @@ sub GetReservesForBranch {
|
|||
return (@transreserv);
|
||||
}
|
||||
|
||||
=head2 GetReserveStatus
|
||||
|
||||
$reservestatus = GetReserveStatus($itemnumber, $biblionumber);
|
||||
|
||||
Take an itemnumber or a biblionumber and return the status of the reserve places on it.
|
||||
If several reserves exist, the reserve with the lower priority is given.
|
||||
|
||||
=cut
|
||||
|
||||
sub GetReserveStatus {
|
||||
my ($itemnumber, $biblionumber) = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my ($sth, $found, $priority);
|
||||
my ($sth, $found, $priority) = (undef, q{}, 0);
|
||||
if ( $itemnumber ) {
|
||||
$sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE itemnumber = ? order by priority LIMIT 1");
|
||||
$sth->execute($itemnumber);
|
||||
($found, $priority) = $sth->fetchrow_array;
|
||||
}
|
||||
|
||||
if ( $biblionumber and not defined $found and not defined $priority ) {
|
||||
$sth = $dbh->prepare("SELECT found, priority FROM reserves WHERE biblionumber = ? order by priority LIMIT 1");
|
||||
$sth->execute($biblionumber);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
($found, $priority) = $sth->fetchrow_array;
|
||||
|
||||
return unless defined $found;
|
||||
return 'Waiting' if $found eq 'W' and $priority == 0;
|
||||
return 'Finished' if $found eq 'F';
|
||||
return 'Reserved' if $priority > 0;
|
||||
|
|
@ -1455,8 +1462,7 @@ sub IsAvailableForItemLevelRequest {
|
|||
if (C4::Context->preference('AllowOnShelfHolds')) {
|
||||
return $available_per_item;
|
||||
} else {
|
||||
my $status = GetReserveStatus($itemnumber);
|
||||
return ($available_per_item and ($item->{onloan} or $status eq "Waiting" or $status = "Reserved"));
|
||||
return ($available_per_item and ($item->{onloan} or GetReserveStatus($itemnumber) eq "Waiting"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue