From: Thomas Berezansky Date: Thu, 23 Jan 2014 17:07:06 +0000 (-0500) Subject: SIP2: Add ids_only parameter to _items functions X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Ftsbere%2Fsip2_ids_only;p=working%2FEvergreen.git SIP2: Add ids_only parameter to _items functions This allows the caller to skip loading of barcodes and/or titles when they are not needed, such as when the plan is to return counts, not details. Signed-off-by: Thomas Berezansky --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm index 62ec4eafde..607b4fd558 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm @@ -456,21 +456,23 @@ sub too_many_billed { # List of outstanding holds placed # sub hold_items { - my ($self, $start, $end) = @_; + my ($self, $start, $end, $ids_only) = @_; syslog('LOG_DEBUG', 'OILS: Patron->hold_items()'); - # all of my open holds - my $holds = $self->{editor}->search_action_hold_request({ + + # all of my open holds + my $holds = $self->{editor}->search_action_hold_request({ usr => $self->{user}->id, fulfillment_time => undef, cancel_time => undef }); - return $self->__format_holds($holds, $start, $end); + return $holds if $ids_only; + return $self->__format_holds($holds, $start, $end); } sub unavail_holds { - my ($self, $start, $end) = @_; + my ($self, $start, $end, $ids_only) = @_; syslog('LOG_DEBUG', 'OILS: Patron->unavail_holds()'); my $holds = $self->{editor}->search_action_hold_request({ @@ -483,6 +485,7 @@ sub unavail_holds { ] }); + return $holds if $ids_only; return $self->__format_holds($holds, $start, $end); } @@ -693,12 +696,14 @@ sub __patron_items_info { sub overdue_items { - my ($self, $start, $end) = @_; + my ($self, $start, $end, $ids_only) = @_; $self->__patron_items_info(); my @overdues = @{$self->{item_info}->{overdue}}; #$overdues[$_] = __circ_to_title($self->{editor}, $overdues[$_]) for @overdues; + return \@overdues if $ids_only; + my @o; syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circs @overdues"); @@ -736,7 +741,7 @@ sub __circ_to_title { # force_bc -- return barcode data regardless of msg64_summary_datatype sub charged_items { - my ($self, $start, $end, $force_bc) = shift; + my ($self, $start, $end, $ids_only, $force_bc) = shift; $self->__patron_items_info(); @@ -747,6 +752,8 @@ sub charged_items { #$charges[$_] = __circ_to_title($self->{editor}, $charges[$_]) for @charges; + return \@charges if $ids_only; + my @c; syslog('LOG_DEBUG', "OILS: charged_items() fleshing circs @charges"); @@ -769,11 +776,15 @@ sub charged_items { } sub fine_items { - my ($self, $start, $end) = @_; + my ($self, $start, $end, $ids_only) = @_; my @fines; eval { my $xacts = $U->simplereq('open-ils.actor', 'open-ils.actor.user.transactions.history.have_balance', $self->{authtoken}, $self->{user}->id); foreach my $xact (@{$xacts}) { + if ($ids_only) { + push @fines, $xact; + next; + } my $line = $xact->balance_owed . " " . $xact->last_billing_type . " "; if ($xact->xact_type eq 'circulation') { my $mods = $U->simplereq('open-ils.circ', 'open-ils.circ.circ_transaction.find_title', $self->{authtoken}, $xact->id); @@ -792,7 +803,7 @@ sub fine_items { # not currently supported sub recall_items { - my ($self, $start, $end) = @_; + my ($self, $start, $end, $ids_only) = @_; return []; } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/RenewAll.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/RenewAll.pm index 675d6adee3..5b199b296d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/RenewAll.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/RenewAll.pm @@ -31,7 +31,7 @@ sub do_renew_all { my $self = shift; my $sip = shift; - my $barcodes = $self->patron->charged_items(undef, undef, 1); + my $barcodes = $self->patron->charged_items(undef, undef, 0, 1); syslog('LOG_INFO', "OILS: RenewalAll for user ". $self->patron->{id} ." and items [@$barcodes]");