added some time diagnostics to checkin process; more org unit caching; do less user...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 20 Oct 2010 20:44:58 +0000 (20:44 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 20 Oct 2010 20:44:58 +0000 (20:44 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18428 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/SIP.pm
Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm

index 6d31703..72c391f 100644 (file)
@@ -6,6 +6,7 @@ package OpenILS::SIP;
 use warnings; use strict;
 
 use Sys::Syslog qw(syslog);
+use Time::HiRes q/time/;
 
 use OpenILS::SIP::Item;
 use OpenILS::SIP::Patron;
@@ -149,10 +150,12 @@ sub clean_text {
     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;
@@ -364,6 +367,8 @@ sub checkin {
        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)");
@@ -386,12 +391,11 @@ sub checkin {
         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;
 }
 
index c435bc0..ae0c646 100644 (file)
@@ -97,7 +97,6 @@ sub new {
     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;
 }
@@ -109,13 +108,16 @@ sub id {
 
 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 {
index 59b630f..42a689c 100644 (file)
@@ -1,15 +1,10 @@
-#
-# 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;
@@ -110,7 +105,9 @@ sub do_checkin {
         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);
@@ -170,7 +167,10 @@ sub do_checkin {
     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;
@@ -181,8 +181,8 @@ sub do_checkin {
             $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';