[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch rel_2_5 updated. ec44ea09dba5bb3ef0617db4ab83e4fbae6d225a

Evergreen Git git at git.evergreen-ils.org
Fri Feb 28 12:41:45 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_5 has been updated
       via  ec44ea09dba5bb3ef0617db4ab83e4fbae6d225a (commit)
       via  0967c3481880f97da400de7b1b9e37706eae7666 (commit)
       via  bb2d39d6a02ebbc0ad1f86d4038a330442aeadb4 (commit)
       via  78b55527ea52c73fe1d33472c1b268e350c00444 (commit)
      from  d970a8c7adac852ca5ddfa640b79d3df788ec2ae (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 ec44ea09dba5bb3ef0617db4ab83e4fbae6d225a
Author: Ben Shum <bshum at biblio.org>
Date:   Fri Feb 28 12:38:36 2014 -0500

    LP1272316 - Stamping upgrade script for pre-calculate-prox-adjustment
    
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index f4257c7..174e0af 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 ('0868', :eg_version); -- berick/dbwells
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0869', :eg_version); -- miker/csharp/bshum
 
 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 0967c3481880f97da400de7b1b9e37706eae7666
Author: Mike Rylander <mrylander at gmail.com>
Date:   Fri Feb 14 12:01:37 2014 -0500

    LP1272316 - 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>
    Signed-off-by: Ben Shum <bshum at biblio.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 1227a7c..12272f4 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 35ab53b..ad78f50 100644
--- a/Open-ILS/src/sql/Pg/090.schema.action.sql
+++ b/Open-ILS/src/sql/Pg/090.schema.action.sql
@@ -1344,4 +1344,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 bb2d39d6a02ebbc0ad1f86d4038a330442aeadb4
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Fri Jan 24 12:33:13 2014 -0500

    LP1272316 - 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>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
index d44c342..cfd9326 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
@@ -1286,15 +1286,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 78b55527ea52c73fe1d33472c1b268e350c00444
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Fri Jan 24 12:24:06 2014 -0500

    LP1272316 - 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>
    Signed-off-by: Ben Shum <bshum at biblio.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 b81e847..1227a7c 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