sub inside_hard_stall_interval {
my ($self) = @_;
if (defined $self->{inside_hard_stall_interval}) {
+ $self->log_hold('already looked up hard stalling state: '.$self->{inside_hard_stall_interval});
return $self->{inside_hard_stall_interval};
}
$self->parent->get_ou_setting(
$self->hold->pickup_lib, 'circ.pickup_hold_stalling.hard', $self->editor) || '0 seconds';
+ $self->log_hold('hard stalling interval '.$hard_stall_interval);
+
my $hold_request_time = $dt_parser->parse_datetime(clean_ISO8601($self->hold->request_time));
my $hard_stall_time = $hold_request_time->clone->add(
seconds => OpenILS::Utils::DateTime->interval_to_seconds($hard_stall_interval)
$self->{inside_hard_stall_interval} = 0
}
+ $self->log_hold('hard stalling state: '.$self->{inside_hard_stall_interval});
return $self->{inside_hard_stall_interval};
}
$copy_hash->{proximity} = $prox;
}
+ # We also need the proximity for the previous target.
+ if ($self->{valid_previous_copy}) {
+ my $prox = $copy_prox_map{$self->{valid_previous_copy}->{id}};
+ $self->{valid_previous_copy}->{proximity} = $prox;
+ }
+
return $self->{weighted_prox_map} = \%prox_map;
}
sub attempt_to_find_copy {
my $self = shift;
- return undef unless @{$self->copies};
+ $self->log_hold("attempting to find a copy normally");
my $max_loops = $self->parent->get_ou_setting(
$self->hold->pickup_lib,
if (grep { $_->{proximity} <= 0 } @{$self->in_use_copies}) {
$have_local_copies = 1;
}
+ $self->log_hold("inside hard stall interval and does ".
+ ($have_local_copies ? "" : "not "). "have in-use local copies");
}
# Pick a copy at random from each tier of the proximity map,
# starting at the lowest proximity and working up, until a
# copy is found that is suitable for targeting.
+ my $no_copies = 1;
for my $prox (sort {$a <=> $b} keys %prox_map) {
my @copies = @{$prox_map{$prox}};
next unless @copies;
+ $no_copies = 0;
$have_local_copies = 1 if ($prox <= 0);
- if ($prox > 0 and $have_local_copies and $self->inside_hard_stall_interval) {
+ $self->log_hold("inside hard stall interval and does ".
+ ($have_local_copies ? "" : "not "). "have testable local copies")
+ if ($self->inside_hard_stall_interval && $prox > 0);
+
+ if ($have_local_copies and $self->inside_hard_stall_interval) {
# Unset valid_previous_copy if it's not local and we have local copies now
$self->{valid_previous_copy} = undef if (
$self->{valid_previous_copy}
and $self->{valid_previous_copy}->{proximity} > 0
);
- last; # No point in looking further "out".
+ last if ($prox > 0); # No point in looking further "out".
}
my $rand = int(rand(scalar(@copies)));
}
}
+ if ($no_copies and $have_local_copies and $self->inside_hard_stall_interval) {
+ # Unset valid_previous_copy if it's not local and we have local copies now
+ $self->{valid_previous_copy} = undef if (
+ $self->{valid_previous_copy}
+ and $self->{valid_previous_copy}->{proximity} > 0
+ );
+ }
+
return undef;
}