use warnings; use strict;
use Sys::Syslog qw(syslog);
+use Time::HiRes q/time/;
use OpenILS::SIP::Item;
use OpenILS::SIP::Patron;
return $text;
}
+my %org_sn_cache;
sub shortname_from_id {
my $id = shift or return;
return $id->shortname if ref $id;
- return editor()->retrieve_actor_org_unit($id)->shortname;
+ return $org_sn_cache{$id} if $org_sn_cache{$id};
+ return $org_sn_cache{$id} = editor()->retrieve_actor_org_unit($id)->shortname;
}
sub patron_barcode_from_id {
my $id = shift or return;
my ($self, $item_id, $inst_id, $trans_date, $return_date,
$current_loc, $item_props, $cancel) = @_;
+ my $start_time = time();
+
$self->verify_session;
syslog('LOG_DEBUG', "OILS: OpenILS::Checkin of item=$item_id (to $inst_id)");
delete $item->{patron};
delete $item->{due_date};
syslog('LOG_INFO', "OILS: Checkin succeeded");
- #editor()->commit;
} else {
- #editor()->xact_rollback;
syslog('LOG_WARNING', "OILS: Checkin failed");
}
+ syslog('LOG_INFO', "OILS: SIP Checkin request took %0.3f seconds", (time() - $start_time));
return $xact;
}
syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s => %s): found patron : barred=%s, card:active=%s",
$key, $patron_id, $user->barred, $user->card->active );
-
bless $self, $type;
return $self;
}
sub name {
my $self = shift;
- my $u = $self->{user};
+ return format_name($self->{user});
+}
+
+sub format_name {
+ my $u = shift;
return OpenILS::SIP::clean_text(
sprintf('%s %s %s',
($u->first_given_name || ''),
($u->second_given_name || ''),
($u->family_name || '')));
-
}
sub home_library {
-#
-# An object to handle checkin status
-#
-
package OpenILS::SIP::Transaction::Checkin;
-
-use warnings;
-use strict;
+use warnings; use strict;
use POSIX qw(strftime);
use Sys::Syslog qw(syslog);
use Data::Dumper;
+use Time::HiRes q/time/;
use OpenILS::SIP;
use OpenILS::SIP::Transaction;
my $method = 'open-ils.circ.checkin';
$method .= '.override' if $override;
+ my $start_time = time();
$resp = $U->simplereq('open-ils.circ', $method, $self->{authtoken}, $args);
+ syslog('LOG_INFO', "OILS: Checkin API call took %0.3f seconds", (time() - $start_time));
if ($debug) {
my $s = Dumper($resp);
if ($self->item->hold) {
my ($pickup_lib_id, $pickup_lib_sn);
- my $holder = OpenILS::SIP->find_patron('usr' => $self->item->hold->usr);
+ my $holder = OpenILS::SIP->editor()->retrieve_actor_user(
+ [$self->item->hold->usr, {flesh => 1, flesh_fields => {au => ['card']}}]);
+
+ my $holder_name = OpenILS::SIP::Patron::format_name($holder);
if (ref $self->item->hold->pickup_lib) {
$pickup_lib_id = $self->item->hold->pickup_lib->id;
$pickup_lib_sn = OpenILS::SIP::shortname_from_id($pickup_lib_id);
}
- $self->item->hold_patron_bcode($holder->id);
- $self->item->hold_patron_name($holder->name);
+ $self->item->hold_patron_bcode( ($holder->card) ? $holder->card->barcode : '');
+ $self->item->hold_patron_name($holder_name);
$self->item->destination_loc($pickup_lib_sn);
my $atype = ($pickup_lib_id == $phys_location) ? '01' : '02';