making hold capture processor faster
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 26 Jul 2005 00:13:24 +0000 (00:13 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 26 Jul 2005 00:13:24 +0000 (00:13 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1468 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
Open-ILS/src/perlmods/OpenILS/Application/Storage/WORM.pm

index 0aa6be5..7ed0dab 100644 (file)
@@ -134,7 +134,8 @@ sub retrieve {
        my $self = shift;
        my $arg = shift;
        if (ref($arg) and UNIVERSAL::isa($arg => 'Fieldmapper')) {
-               my ($col) = $self->columns('Primary');
+               my ($col) = $self->primary_column;
+               $log->debug("Using field $col as the primary key", INTERNAL);
                $arg = $arg->$col;
        }
        $log->debug("Retrieving $self with $arg", INTERNAL);
index 27ae674..742aaec 100644 (file)
@@ -402,7 +402,6 @@ sub hold_copy_targeter {
                $year, $mon, $mday, $hour, $min, $sec
        );
 
-       $self->method_lookup( 'open-ils.storage.transaction.begin')->run($client);
 
        ($statuses) = $self->method_lookup('open-ils.storage.direct.config.copy_status.search.holdable.atomic')->run('t');
 
@@ -436,6 +435,9 @@ sub hold_copy_targeter {
 
        for my $hold (@$holds) {
                try {
+                       $self->method_lookup( 'open-ils.storage.transaction.begin')->run($client);
+                       $client->respond("Processing hold ".$hold->id."...\n");
+
                        my $copies;
 
                        $copies = $self->metarecord_hold_capture($hold) if ($hold->hold_type eq 'M');
@@ -449,7 +451,6 @@ sub hold_copy_targeter {
                        
                        $copies = $self->copy_hold_capture($hold) if ($hold->hold_type eq 'C');
 
-                       $client->respond("Processing hold ".$hold->id."...\n");
                        unless (ref $copies || !@$copies) {
                                $client->respond("\tNo copies available for targeting at all!\n");
                        }
@@ -504,6 +505,7 @@ sub hold_copy_targeter {
                        }
 
                        $hold->prev_check_time( 'now' );
+                       $client->respond("\tUpdating hold ".$hold->id." with new 'current_copy' for hold fulfillment.\n");
                        my ($r) = $self->method_lookup('open-ils.storage.direct.action.hold_request.update')->run( $hold );
 
                        $client->respond("\tProcessing of hold ".$hold->id." complete.\n");
@@ -514,6 +516,7 @@ sub hold_copy_targeter {
                        $client->respond("\tProcessing of hold ".$hold->id." failed!.\n\t\t$e\n");
                        $self->method_lookup('open-ils.storage.transaction.rollback')->run;
                };
+               $self->method_lookup( 'open-ils.storage.transaction.commit')->run($client);
        }
        $self->{user_filter}->disconnect;
        $self->{user_filter}->finish;
@@ -571,12 +574,11 @@ sub copy_hold_capture {
 
        return unless ($count);
        
-       my @old_maps = $self->method_lookup('open-ils.storage.direct.action.hold_copy_map.search.hold')->run( $hold->id );
-
-       $self->method_lookup('open-ils.storage.direct.action.hold_copy_map.batch.delete')->run(@old_maps );
+       $self->method_lookup('open-ils.storage.direct.action.hold_copy_map.mass_delete')->run( { hold => $hold->id } );
        
        my @maps;
        for my $c (@copies) {
+               $self->{client}->respond( "\tCreating hold-copy map for ".$hold->id." <-> ".$c->id."\n");
                my $m = new Fieldmapper::action::hold_copy_map;
                $m->hold( $hold->id );
                $m->target_copy( $c->id );
index ae4bb3a..d90a39a 100644 (file)
@@ -17,6 +17,7 @@ sub copy_proximity {
 
        $cp = $cp->id if (ref $cp);
        $cp = asset::copy->retrieve($cp);
+       return 999 unless $copy;
        my $ol = $cp->call_number->owning_lib;
 
        return asset::copy->db_Main->selectcol_arrayref('SELECT actor.org_unit_proximity(?,?)',{},"$ol","$org")->[0];
index 00e0318..1cff1a5 100644 (file)
@@ -314,7 +314,7 @@ sub wormize {
 
                unless ($no_map) {
                        my ($mr) = $mr_lookup->run( $entry->fingerprint );
-                       if (!@$mr) {
+                       if (!$mr || !@$mr) {
                                $log->debug("No metarecord found for fingerprint [".$entry->fingerprint."]; Creating a new one", INFO);
                                $mr = new Fieldmapper::metabib::metarecord;
                                $mr->fingerprint( $entry->fingerprint );