From 35cf48d64e618fb75afc45fb407f400a424ea95d Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 9 Aug 2010 14:35:16 +0000 Subject: [PATCH] combine circ and user fetch into 1 cstore call for SIP items. minor cleanup git-svn-id: svn://svn.open-ils.org/ILS/trunk@17137 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/SIP/Item.pm | 35 +++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm index e5e453276c..fe603108ab 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm @@ -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; -- 2.43.2