Effectively FF r145
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 29 Nov 2012 22:04:00 +0000 (17:04 -0500)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 5 Dec 2012 17:39:36 +0000 (12:39 -0500)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/action.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/asset.pm

index 32e1529..efa3896 100644 (file)
@@ -4049,6 +4049,7 @@ SELECT  usr,
                        <field name="hold" reporter:datatype="link"/>
                        <field name="id" reporter:datatype="id" />
                        <field name="target_copy" reporter:datatype="link"/>
+                       <field name="proximity" reporter:datatype="number"/>
                </fields>
                <links>
                        <link field="hold" reltype="has_a" key="id" map="" class="ahr"/>
index 4868664..c793710 100644 (file)
@@ -114,7 +114,7 @@ package action::hold_copy_map;
 use base qw/action/;
 __PACKAGE__->table('action_hold_copy_map');
 __PACKAGE__->columns(Primary => 'id');
-__PACKAGE__->columns(Essential => qw/hold target_copy/);
+__PACKAGE__->columns(Essential => qw/hold target_copy proximity/);
 
 #-------------------------------------------------------------------------------
 
index 4101309..536cdb1 100644 (file)
@@ -1483,7 +1483,7 @@ sub new_hold_copy_targeter {
                                        }
                                }
 
-                               $prox_list = create_prox_list( $self, $pu_lib, $all_copies );
+                               $prox_list = create_prox_list( $self, $pu_lib, $all_copies, $hold );
 
                                $client->status( new OpenSRF::DomainObject::oilsContinueStatus );
 
@@ -1970,12 +1970,13 @@ sub create_prox_list {
        my $self = shift;
        my $lib = shift;
        my $copies = shift;
+       my $hold = shift;
 
        my $actor = OpenSRF::AppSession->create('open-ils.actor');
 
        my @prox_list;
        for my $cp (@$copies) {
-               my ($prox) = $self->method_lookup('open-ils.storage.asset.copy.proximity')->run( $cp, $lib );
+               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;
index 42fb891..5cbb607 100644 (file)
@@ -397,9 +397,26 @@ sub copy_proximity {
 
        my $cp = shift;
        my $org = shift;
+       my $hold = shift;
 
        return unless ($cp && $org);
 
+       if ($hold) {
+          my $prox = action::hold_request->db_Main->selectrow_hashref(
+                       'SELECT proximity AS prox FROM action.hold_copy_map WHERE hold = ? and target_copy = ?',
+                       {},
+                       "$hold",
+                       "$cp"
+               )->{prox} || action::hold_request->db_Main->selectrow_hashref(
+                       'SELECT action.hold_copy_calculated_proximity(?,?,?) AS prox',
+                       {},
+                       "$hold",
+                       "$cp",
+                       "$org"
+               )->{prox};
+               return int($prox * 100.0);
+       }
+
        $cp = asset::copy->retrieve($cp) unless (ref($cp));
 
        return unless $cp;