[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch rel_2_4 updated. fb5f420ce22528a2a8086ef79f5df61857110d52

Evergreen Git git at git.evergreen-ils.org
Sun Mar 2 16:33:17 EST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_4 has been updated
       via  fb5f420ce22528a2a8086ef79f5df61857110d52 (commit)
       via  9fe9edc174140f5512b26f634efc58c68ef3e1bf (commit)
       via  25b4766d74fd90042dc1c7daee23f4d3f242ee5c (commit)
       via  3e8b0991c34d77b5da0a21f7b24e8a3d2af2c4bb (commit)
      from  ffe339da468790ae567a884913ebea7dec0bc0de (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fb5f420ce22528a2a8086ef79f5df61857110d52
Author: Mike Rylander <mrylander at gmail.com>
Date:   Sun Mar 2 16:32:20 2014 -0500

    Stamping upgrade script for pre-calculate-prox-adjustment for backport
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index ea5ef0b..eb94f19 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0862', :eg_version); -- dbs/dbwells
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0869', :eg_version); -- miker
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.pre-calculate-prox-adjustment.sql b/Open-ILS/src/sql/Pg/upgrade/0869.schema.pre-calculate-prox-adjustment.sql
similarity index 90%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.pre-calculate-prox-adjustment.sql
rename to Open-ILS/src/sql/Pg/upgrade/0869.schema.pre-calculate-prox-adjustment.sql
index 723699d..0e18119 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.pre-calculate-prox-adjustment.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0869.schema.pre-calculate-prox-adjustment.sql
@@ -1,5 +1,7 @@
 BEGIN;
 
+SELECT evergreen.upgrade_deps_block_check('0869', :eg_version);
+
 CREATE OR REPLACE FUNCTION action.hold_copy_calculated_proximity_update () RETURNS TRIGGER AS $f$
 BEGIN
     NEW.proximity := action.hold_copy_calculated_proximity(NEW.hold,NEW.target_copy);

commit 9fe9edc174140f5512b26f634efc58c68ef3e1bf
Author: Mike Rylander <mrylander at gmail.com>
Date:   Sun Mar 2 16:29:27 2014 -0500

    Calculate proximity in the DB for speed
    
    We need to calculate and store a (potenially adjusted) proxmity for
    each hold and copy for use in targetting and optimization of op
    capture.  Before this commit, we do that within the hold target
    code itself.  Now we'll do it when the hold-copy map is inserted,
    because we have the same information available at that time as we
    have in the targeter.  This will both speed up the apparent cost of
    the calculation, because it avoids the cost of a network round-trip,
    and the total number of SELECTs we must issue, because the proximity
    value will now be cached for use by the proximity map function.
    
    Backward compatability is retained for the create_prox_map() function
    in case any other code is depending on that.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
index 33beb36..da10bde 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
@@ -1555,15 +1555,17 @@ sub new_hold_copy_targeter {
             $found_copy = 1 if($find_copy and grep $_ == $find_copy, @$all_copies);
 
 			# map the potentials, so that we can pick up checkins
-			# XXX Loop-based targeting may require that /only/ copies from this loop should be added to
-			# XXX the potentials list.  If this is the cased, hold_copy_map creation will move down further.
+            my $hold_copy_map = {};
+            $hold_copy_map->{$_->hold}->{$_->target_copy} = $_->proximity
+                for (
+                    map {
+                        action::hold_copy_map->create( { hold => $hold->id, target_copy => $_->id } )
+                    } @$all_copies
+                );
+
 			my $pu_lib = ''.$hold->pickup_lib;
-			my $prox_list = create_prox_list( $self, $pu_lib, $all_copies, $hold );
+            my $prox_list = create_prox_list( $self, $pu_lib, $all_copies, $hold, $hold_copy_map );
 			$log->debug( "\tMapping ".scalar(@$all_copies)." potential copies for hold ".$hold->id);
-			for my $prox ( keys %$prox_list ) {
-				action::hold_copy_map->create( { proximity => $prox, hold => $hold->id, target_copy => $_ } )
-					for keys( %{{ map { $_->id => 1 } @{$$prox_list{$prox}} }} );
-			}
 
 			#$client->status( new OpenSRF::DomainObject::oilsContinueStatus );
 
@@ -1647,7 +1649,7 @@ sub new_hold_copy_targeter {
 			$prox_list = create_prox_list(
 				$self, $pu_lib,
 				[ grep { $_->status == 0 || $_->status == 7 } @good_copies ],
-				$hold
+                $hold, $hold_copy_map
 			);
 
 			$all_copies = [ grep { ''.$_->circ_lib ne $pu_lib && ( $_->status == 0 || $_->status == 7 ) } @good_copies ];
@@ -1748,7 +1750,7 @@ sub new_hold_copy_targeter {
 						die "OK\n";
 					}
 
-    				$prox_list = create_prox_list( $self, $pu_lib, $all_copies, $hold );
+                    $prox_list = create_prox_list( $self, $pu_lib, $all_copies, $hold, $hold_copy_map );
 
     				$client->status( new OpenSRF::DomainObject::oilsContinueStatus );
 
@@ -2242,11 +2244,13 @@ sub create_prox_list {
 	my $lib = shift;
 	my $copies = shift;
 	my $hold = shift;
+    my $hold_copy_map = shift || {};
 
 	my %prox_list;
     my $editor = new_editor;
 	for my $cp (@$copies) {
-		my ($prox) = $self->method_lookup('open-ils.storage.asset.copy.proximity')->run( $cp, $lib, $hold );
+        my $prox = $hold_copy_map->{"$hold"}->{"$cp"}; # Allow CDBI stringification to get the pkey
+        ($prox) = $self->method_lookup('open-ils.storage.asset.copy.proximity')->run( $cp, $lib, $hold ) unless (defined $prox);
 		next unless (defined($prox));
 
         my $copy_circ_lib = ''.$cp->circ_lib;
diff --git a/Open-ILS/src/sql/Pg/090.schema.action.sql b/Open-ILS/src/sql/Pg/090.schema.action.sql
index 1973867..b226fcd 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -1061,4 +1061,13 @@ BEGIN
 END;
 $f$ LANGUAGE PLPGSQL;
 
+CREATE OR REPLACE FUNCTION action.hold_copy_calculated_proximity_update () RETURNS TRIGGER AS $f$
+BEGIN
+    NEW.proximity := action.hold_copy_calculated_proximity(NEW.hold,NEW.target_copy);
+    RETURN NEW;
+END;
+$f$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER hold_copy_proximity_update_tgr BEFORE INSERT OR UPDATE ON action.hold_copy_map FOR EACH ROW EXECUTE PROCEDURE action.hold_copy_calculated_proximity_update ();
+
 COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.pre-calculate-prox-adjustment.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.pre-calculate-prox-adjustment.sql
new file mode 100644
index 0000000..723699d
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.pre-calculate-prox-adjustment.sql
@@ -0,0 +1,16 @@
+BEGIN;
+
+CREATE OR REPLACE FUNCTION action.hold_copy_calculated_proximity_update () RETURNS TRIGGER AS $f$
+BEGIN
+    NEW.proximity := action.hold_copy_calculated_proximity(NEW.hold,NEW.target_copy);
+    RETURN NEW;
+END;
+$f$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER hold_copy_proximity_update_tgr BEFORE INSERT OR UPDATE ON action.hold_copy_map FOR EACH ROW EXECUTE PROCEDURE action.hold_copy_calculated_proximity_update ();
+
+-- Now, cause the update we need in a HOT-friendly manner (http://pgsql.tapoueh.org/site/html/misc/hot.html)
+UPDATE action.hold_copy_map SET proximity = proximity WHERE proximity IS NULL;
+
+COMMIT;
+

commit 25b4766d74fd90042dc1c7daee23f4d3f242ee5c
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Fri Jan 24 12:33:13 2014 -0500

    Followup to make ou_ancestor_setting() even faster
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
index db1d2f2..5d118a7 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
@@ -1285,15 +1285,17 @@ sub ou_ancestor_setting {
     $e = $e || OpenILS::Utils::CStoreEditor->new(
         (defined $auth) ? (authtoken => $auth) : ()
     );
-    my $coust = $e->retrieve_config_org_unit_setting_type([
-        $name, {flesh => 1, flesh_fields => {coust => ['view_perm']}}
-    ]);
 
-    if ($auth && $coust && $coust->view_perm) {
-        # And you can't have permission if you don't have a valid session.
-        return undef if not $e->checkauth;
-        # And now that we know you MIGHT have permission, we check it.
-        return undef if not $e->allowed($coust->view_perm->code, $orgid);
+    if ($auth) {
+        my $coust = $e->retrieve_config_org_unit_setting_type([
+            $name, {flesh => 1, flesh_fields => {coust => ['view_perm']}}
+        ]);
+        if ($coust && $coust->view_perm) {
+            # And you can't have permission if you don't have a valid session.
+            return undef if not $e->checkauth;
+            # And now that we know you MIGHT have permission, we check it.
+            return undef if not $e->allowed($coust->view_perm->code, $orgid);
+        }
     }
 
     my $query = {from => ['actor.org_unit_ancestor_setting', $name, $orgid]};

commit 3e8b0991c34d77b5da0a21f7b24e8a3d2af2c4bb
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Sun Mar 2 16:25:43 2014 -0500

    Speed up these settings lookups in the hold targeter that get repeated a ...
    
    ... lot when there are lots of copies for a hold.
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
index b1ac6eb..33beb36 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
@@ -9,6 +9,7 @@ use OpenSRF::AppSession;
 use OpenSRF::EX qw/:try/;
 use OpenILS::Utils::Fieldmapper;
 use OpenILS::Utils::PermitHold;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
 use DateTime;
 use DateTime::Format::ISO8601;
 use OpenILS::Utils::Penalty;
@@ -58,12 +59,12 @@ sub isTrue {
 
 sub ou_ancestor_setting_value_or_cache {
 	# cache should be specific to setting
-	my ($actor, $org_id, $setting, $cache) = @_;
+    my ($e, $org_id, $setting, $cache) = @_;
 
 	if (not exists $cache->{$org_id}) {
-		my $r = $actor->request(
-			'open-ils.actor.ou_setting.ancestor_default', $org_id, $setting
-		)->gather(1);
+        my $r = $U->ou_ancestor_setting(
+            $org_id, $setting, $e # undef $e is ok
+        );
 
 		if ($r) {
 			$cache->{$org_id} = $r->{value};
@@ -1385,6 +1386,7 @@ sub new_hold_copy_targeter {
 
 	my @successes;
 	my $actor = OpenSRF::AppSession->create('open-ils.actor');
+    my $editor = new_editor;
 
 	my $target_when_closed = {};
 	my $target_when_closed_if_at_pickup_lib = {};
@@ -1575,7 +1577,7 @@ sub new_hold_copy_targeter {
 
 				if (''.$hold->pickup_lib eq ''.$c->circ_lib) {
 					$ignore_closing = ou_ancestor_setting_value_or_cache(
-                        $actor,
+                        $editor,
 						''.$c->circ_lib,
 						'circ.holds.target_when_closed_if_at_pickup_lib',
 						$target_when_closed_if_at_pickup_lib
@@ -1584,7 +1586,7 @@ sub new_hold_copy_targeter {
 				if (not $ignore_closing) {  # one more chance to find a reason
 											# to ignore OU closedness.
 					$ignore_closing = ou_ancestor_setting_value_or_cache(
-                        $actor,
+                        $editor,
 						''.$c->circ_lib,
 						'circ.holds.target_when_closed',
 						$target_when_closed
@@ -1663,9 +1665,9 @@ sub new_hold_copy_targeter {
 			if (!$best) {
 				$log->debug("\tNothing at the pickup lib, looking elsewhere among ".scalar(@$all_copies)." copies");
 
-				$self->{max_loops}{$pu_lib} = $actor->request(
-					'open-ils.actor.ou_setting.ancestor_default' => $pu_lib => 'circ.holds.max_org_unit_target_loops'
-				)->gather(1);
+                $self->{max_loops}{$pu_lib} = $U->ou_ancestor_setting(
+                    $pu_lib, 'circ.holds.max_org_unit_target_loops', $editor
+                );
 
 				if (defined($self->{max_loops}{$pu_lib})) {
 					$self->{max_loops}{$pu_lib} = $self->{max_loops}{$pu_lib}{value};
@@ -2241,18 +2243,17 @@ sub create_prox_list {
 	my $copies = shift;
 	my $hold = shift;
 
-	my $actor = OpenSRF::AppSession->create('open-ils.actor');
-
 	my %prox_list;
+    my $editor = new_editor;
 	for my $cp (@$copies) {
 		my ($prox) = $self->method_lookup('open-ils.storage.asset.copy.proximity')->run( $cp, $lib, $hold );
 		next unless (defined($prox));
 
         my $copy_circ_lib = ''.$cp->circ_lib;
 		# Fetch the weighting value for hold targeting, defaulting to 1
-		$self->{target_weight}{$copy_circ_lib} ||= $actor->request(
-			'open-ils.actor.ou_setting.ancestor_default' => $copy_circ_lib.'' => 'circ.holds.org_unit_target_weight'
-		)->gather(1);
+        $self->{target_weight}{$copy_circ_lib} ||= $U->ou_ancestor_setting(
+            $copy_circ_lib.'', 'circ.holds.org_unit_target_weight', $editor
+        );
         $self->{target_weight}{$copy_circ_lib} = $self->{target_weight}{$copy_circ_lib}{value} if (ref $self->{target_weight}{$copy_circ_lib});
         $self->{target_weight}{$copy_circ_lib} ||= 1;
 

-----------------------------------------------------------------------

Summary of changes:
 .../perlmods/lib/OpenILS/Application/AppUtils.pm   |   18 ++++---
 .../Application/Storage/Publisher/action.pm        |   53 +++++++++++---------
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/090.schema.action.sql          |    9 +++
 .../0869.schema.pre-calculate-prox-adjustment.sql  |   18 +++++++
 5 files changed, 67 insertions(+), 33 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0869.schema.pre-calculate-prox-adjustment.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list