From: erickson Date: Thu, 3 Aug 2006 18:42:13 +0000 (+0000) Subject: moved penalty server to cstore since it is called a lot - speed X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3b85fb09f1ae850eafd35cd005eb1217ed8a0da4;p=Evergreen.git moved penalty server to cstore since it is called a lot - speed git-svn-id: svn://svn.open-ils.org/ILS/trunk@5254 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Penalty.pm b/Open-ILS/src/perlmods/OpenILS/Application/Penalty.pm index a233c032d8..c4ceda3137 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Penalty.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Penalty.pm @@ -9,6 +9,7 @@ use OpenILS::Application::Circ::ScriptBuilder; use OpenSRF::Utils::SettingsClient; use OpenILS::Application::AppUtils; use OpenSRF::Utils::Logger qw(:logger); +use OpenILS::Utils::CStoreEditor qw/:funcs/; use base 'OpenSRF::Application'; my $U = "OpenILS::Application::AppUtils"; @@ -122,14 +123,13 @@ sub update_patron_penalties { my $penalties = $args{penalties}; my $pid = $patron->id; + $logger->debug("updating penalties for patron $pid => @$penalties"); + my $editor = new_editor(xact =>1); - my $session = $U->start_db_session(); # - fetch the current penalties - my $existing = $session->request( - 'open-ils.storage.direct.actor.'. - 'user_standing_penalty.search.usr.atomic', $pid )->gather(1); + my $existing = $editor->search_actor_user_standing_penalty({usr=>$pid}); my @types; push( @types, $_->penalty_type ) for @$existing; @@ -145,9 +145,8 @@ sub update_patron_penalties { $logger->activity("penalty: removing user penalty ". $e->penalty_type . " from user $pid"); - my $s = $session->request( - 'open-ils.storage.direct.actor.user_standing_penalty.delete', $e->id )->gather(1); - return $U->DB_UPDATE_FAILED($e) unless defined($s); + $editor->delete_actor_user_standing_penalty($e) + or return $editor->event; } } @@ -161,13 +160,12 @@ sub update_patron_penalties { $newp->penalty_type( $p ); $newp->usr( $pid ); - my $s = $session->request( - 'open-ils.storage.direct.actor.user_standing_penalty.create', $newp )->gather(1); - return $U->DB_UPDATE_FAILED($p) unless $s; + $editor->create_actor_user_standing_penalty($newp) + or return $editor->event; } } - $U->commit_db_session($session); + $editor->commit; return undef; }