From 4bb753ed9f1dfc8820e4c9ab534111315dec36c2 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 27 Jul 2006 17:58:59 +0000 Subject: [PATCH] improving "nearest_hold" git-svn-id: svn://svn.open-ils.org/ILS/trunk@5129 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Storage/Publisher/action.pm | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 33dd5cde94..1386f5d0d8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -162,23 +162,27 @@ sub nearest_hold { my $client = shift; my $pl = shift; my $cp = shift; + my $limit = int(shift()) || 10; - my ($id) = action::hold_request->db_Main->selectrow_array(<<" SQL", {}, $pl,$cp); + my ($id) = action::hold_request->db_Main->selectrow_array(<<" SQL", {}, $cp, $pl); SELECT h.id FROM action.hold_request h JOIN action.hold_copy_map hm ON (hm.hold = h.id) - WHERE h.pickup_lib = ? - AND hm.target_copy = ? + WHERE hm.target_copy = ? AND h.capture_time IS NULL - ORDER BY h.pickup_lib - (SELECT home_ou FROM actor.usr a WHERE a.id = h.usr), h.selection_depth DESC, h.request_time - LIMIT 1 + ORDER BY + actor.org_unit_proximity(h.pickup_lib, ?), + h.selection_depth DESC, + h.request_time + LIMIT $limit SQL return $id; } __PACKAGE__->register_method( - api_name => 'open-ils.storage.action.hold_request.nearest_hold', - api_level => 1, - method => 'nearest_hold', + api_name => 'open-ils.storage.action.hold_request.nearest_hold', + api_level => 1, + stream => 1, + method => 'nearest_hold', ); sub next_resp_group_id { @@ -1069,7 +1073,7 @@ sub create_prox_list { my @prox_list; for my $cp (@$copies) { - my ($prox) = $self->method_lookup('open-ils.storage.asset.copy.proximity')->run( $cp->id, $lib ); + my ($prox) = $self->method_lookup('open-ils.storage.asset.copy.proximity')->run( $cp, $lib ); next unless (defined($prox)); $prox_list[$prox] = [] unless defined($prox_list[$prox]); push @{$prox_list[$prox]}, $cp; -- 2.43.2