combine circ and user fetch into 1 cstore call for SIP items. minor cleanup
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 9 Aug 2010 14:35:16 +0000 (14:35 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 9 Aug 2010 14:35:16 +0000 (14:35 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17137 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/SIP/Item.pm

index e5e4532..fe60310 100644 (file)
@@ -93,27 +93,32 @@ sub new {
                                }
                        }
                ]
-    );
-
-
-    $copy = $copy->[0];
+    )->[0];
 
        if(!$copy) {
                syslog("LOG_DEBUG", "OILS: Item '%s' : not found", $item_id);
                return undef;
        }
 
-       my ($circ) = $U->fetch_open_circulation($copy->id);
-       if ($circ) {
-               # if i am checked out, set $self->{patron} to the user's barcode
-               my $user = $e->retrieve_actor_user(
-                       [
-                               $circ->usr,
-                               { flesh => 1, flesh_fields => { "au" => [ 'card' ] } }
-                       ]
-               );
-
-        my $bc = ($user) ? $user->card->barcode : "";
+    my $circ = $e->search_action_circulation([
+        {
+            target_copy => $copy->id,
+            stop_fines_time => undef, 
+            checkin_time => undef
+        },
+        {
+            flesh => 2,
+            flesh_fields => {
+                circ => ['usr'],
+                au => ['card']
+            }
+        }
+    ])->[0];
+
+    if($circ) {
+
+        my $user = $circ->usr;
+        my $bc = ($user->card) ? $user->card->barcode : '';
         $self->{patron} = $bc;
         $self->{patron_object} = $user;