From 7e4c136ecb3db6b8c6e6a3dfecefcc9a882b7ac3 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 26 Jul 2005 00:13:24 +0000 Subject: [PATCH] making hold capture processor faster git-svn-id: svn://svn.open-ils.org/ILS/trunk@1468 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Storage/CDBI.pm | 3 ++- .../OpenILS/Application/Storage/Publisher/action.pm | 12 +++++++----- .../OpenILS/Application/Storage/Publisher/asset.pm | 1 + .../src/perlmods/OpenILS/Application/Storage/WORM.pm | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm index 0aa6be59d9..7ed0dab0a3 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm @@ -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); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm index 27ae6744a0..742aaec5c9 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -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 ); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm index ae4bb3ab99..d90a39a72b 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm @@ -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]; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/WORM.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/WORM.pm index 00e0318c54..1cff1a58ed 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/WORM.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/WORM.pm @@ -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 ); -- 2.43.2