From: erickson Date: Thu, 28 Oct 2010 15:13:30 +0000 (+0000) Subject: condensed SIP patron lookup by barcode into 1 cstore call; provided option for slimm... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b22693169c2ae34f4966a3b27f76012929e86284;p=evergreen%2Ftadl.git condensed SIP patron lookup by barcode into 1 cstore call; provided option for slimmed-down user object fetching in the case of checkin, where all we really need is the barcode of the user on the circulation git-svn-id: svn://svn.open-ils.org/ILS/trunk@18519 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/SIP.pm b/Open-ILS/src/perlmods/OpenILS/SIP.pm index 72c391fbca..fe312ffd2f 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP.pm @@ -387,7 +387,7 @@ sub checkin { $xact->do_checkin( $self, $inst_id, $trans_date, $return_date, $current_loc, $item_props ); if ($xact->ok) { - $xact->patron($self->find_patron(usr => $xact->{circ_user_id})) if $xact->{circ_user_id}; + $xact->patron($self->find_patron(usr => $xact->{circ_user_id}, slim_user => 1)) if $xact->{circ_user_id}; delete $item->{patron}; delete $item->{due_date}; syslog('LOG_INFO', "OILS: Checkin succeeded"); diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm index ae0c646711..5b1d1217ea 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm @@ -38,6 +38,7 @@ sub new { my $class = shift; my $key = (@_ > 1) ? shift : 'barcode'; # if we have multiple args, the first is the key index (default barcode) my $patron_id = shift; + my %args = @_; if ($key ne 'usr' and $key ne 'barcode') { syslog("LOG_ERROR", "Patron (card) lookup requested by illegeal key '$key'"); @@ -55,34 +56,43 @@ sub new { syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s => %s): searching...", $key, $patron_id); my $e = OpenILS::SIP->editor(); + + my $usr_flesh = { + flesh => 2, + flesh_fields => { + au => [ + "card", + "standing_penalties", + "addresses", + "billing_address", + "mailing_address", + 'profile', + ], + ausp => ['standing_penalty'] + } + }; + + # in some cases, we don't need all of this data. Only fetch the user + barcode + $usr_flesh = {flesh => 1, flesh_fields => {au => ['card']}} if $args{slim_user}; - my $user_id = $patron_id; - if($key eq 'barcode') { - my $card = $e->search_actor_card({barcode => $patron_id})->[0]; - unless($card) { + my $user; + if($key eq 'barcode') { # retrieve user by barcode + + $$usr_flesh{flesh} += 1; + $$usr_flesh{flesh_fields}{ac} = ['usr']; + + my $card = $e->search_actor_card([{barcode => $patron_id}, $usr_flesh])->[0]; + + if(!$card) { syslog("LOG_WARNING", "No such patron barcode: $patron_id"); return undef; } - $user_id = $card->usr; - } - my $user = $e->retrieve_actor_user([ - $user_id, - { - flesh => 2, - flesh_fields => { - au => [ - "card", - "standing_penalties", - "addresses", - "billing_address", - "mailing_address", - 'profile', - ], - ausp => ['standing_penalty'] - } - } - ]); + $user = $card->usr; + + } else { + $user = $e->retrieve_actor_user([$patron_id, $usr_flesh]); + } if(!$user) { syslog("LOG_WARNING", "OILS: Unable to find patron %s => %s", $key, $patron_id);