[open-ils-commits] r11814 - in trunk/Open-ILS/src/perlmods/OpenILS: Application Application/Circ Application/Storage/Publisher Utils
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jan 13 12:44:07 EST 2009
Author: erickson
Date: 2009-01-13 12:44:05 -0500 (Tue, 13 Jan 2009)
New Revision: 11814
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
trunk/Open-ILS/src/perlmods/OpenILS/Utils/Penalty.pm
Log:
return penalty objects from retrieve_penalties. flesh the event desc with the penalty label for circ panelaties. to reduce overhead, call the local penalty calculater from the fine generator
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-01-13 17:39:05 UTC (rev 11813)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-01-13 17:44:05 UTC (rev 11814)
@@ -1110,9 +1110,24 @@
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('VIEW_USER');
- return $U->storagereq(
+
+ my $bcids = [];
+ if(my $bc = $$search_hash{card}{value}) {
+ $bcids = $e->json_query({
+ select => {ac => ['usr']},
+ from => {ac => {au => {field => 'id', fkey => 'usr'}}},
+ where => {'+ac' => {barcode => {like => "$bc%"}, active => 't'}, '+au' => {deleted => 'f'}}
+ });
+ $bcids = map [ {$_->{usr} ] @$bcids;
+ }
+
+ my $ids = $U->storagereq(
"open-ils.storage.actor.user.crazy_search", $search_hash,
$search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_depth);
+
+ my %h; # dedup
+ $h{$_} = 1 for (@$bcids, $ids);
+ return [keys %h];
}
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2009-01-13 17:39:05 UTC (rev 11813)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm 2009-01-13 17:44:05 UTC (rev 11814)
@@ -1064,18 +1064,6 @@
}
-
-# ---------------------------------------------------------------------
-# Updates and returns the patron penalties
-# ---------------------------------------------------------------------
-sub update_patron_penalties_nonblock {
- my( $self, %args ) = @_;
- return $self->simplereq(
- 'open-ils.penalty',
- 'open-ils.penalty.patron_penalty.calculate', {background => 1}
- );
-}
-
sub fetch_bill {
my( $self, $billid ) = @_;
$logger->debug("Fetching billing $billid");
@@ -1085,8 +1073,6 @@
return($bill, $evt);
}
-
-
my $ORG_TREE;
sub fetch_org_tree {
my $self = shift;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm 2009-01-13 17:39:05 UTC (rev 11813)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm 2009-01-13 17:44:05 UTC (rev 11814)
@@ -838,7 +838,13 @@
my $penalties = OpenILS::Utils::Penalty->retrieve_penalties($self->editor, $patronid, $self->circ_lib, $mask);
$penalties = $penalties->{fatal_penalties};
- push(@allevents, OpenILS::Event->new($_)) for (@$penalties, @$patron_events);
+ for my $pen (@$penalties) {
+ my $event = OpenILS::Event->new($pen->name);
+ $event->{desc} = $pen->label;
+ push(@allevents, $event);
+ }
+
+ push(@allevents, OpenILS::Event->new($_)) for (@$patron_events);
}
$logger->info("circulator: permit_patron script returned events: @allevents") if @allevents;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm 2009-01-13 17:39:05 UTC (rev 11813)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm 2009-01-13 17:44:05 UTC (rev 11814)
@@ -8,6 +8,7 @@
use OpenILS::Utils::PermitHold;
use DateTime;
use DateTime::Format::ISO8601;
+use OpenILS::Penalty;
sub isTrue {
my $v = shift;
@@ -601,7 +602,6 @@
my %hoo = map { ( $_->id => $_ ) } actor::org_unit::hours_of_operation->retrieve_all;
- my $penalty = OpenSRF::AppSession->create('open-ils.penalty');
for my $c (@circs) {
try {
@@ -765,13 +765,7 @@
$self->method_lookup('open-ils.storage.transaction.commit')->run;
- $penalty->request(
- 'open-ils.penalty.patron_penalty.calculate',
- { patron => $c->usr->to_fieldmapper,
- update => 1,
- background => 1,
- }
- )->gather(1);
+ OpenILS::Utils::Penalty->calculate_penalties(undef, $c->usr, $c->circ_lib);
} catch Error with {
my $e = shift;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/Penalty.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/Penalty.pm 2009-01-13 17:39:05 UTC (rev 11813)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/Penalty.pm 2009-01-13 17:44:05 UTC (rev 11814)
@@ -17,6 +17,12 @@
sub calculate_penalties {
my($class, $e, $user_id, $context_org) = @_;
+ my $rollback = 0;
+ unless($e) {
+ $e = new_editor(xact =>1);
+ $rollback = 1;
+ }
+
my $penalties = $e->json_query({from => ['actor.calculate_system_penalties',$user_id, $context_org]});
for my $pen_obj (@$penalties) {
@@ -37,6 +43,7 @@
}
}
+ $e->rollback if $rollback;
return undef;
}
@@ -56,13 +63,13 @@
if($p->standing_penalty->block_list) {
for my $m (@fatal_mask) {
if($p->standing_penalty->block_list =~ /$m/) {
- push(@fatal, $p->standing_penalty->name);
+ push(@fatal, $p->standing_penalty);
$pushed = 1;
last;
}
}
}
- push(@info, $p->standing_penalty->name) unless $pushed;
+ push(@info, $p->standing_penalty) unless $pushed;
}
return {fatal_penalties => \@fatal, info_penalties => \@info};
More information about the open-ils-commits
mailing list