From ea890b0e1aa2f4e03278c5dc1ce6282b66fd2d85 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 1 Feb 2010 15:10:57 +0000 Subject: [PATCH] repaired hold queue position logic to account for holds that have no potential copies assigned git-svn-id: svn://svn.open-ils.org/ILS/trunk@15412 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ/Holds.pm | 47 +++++++++++++++------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index aabe99aca3..1ddd5ccdb2 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -921,31 +921,48 @@ sub retrieve_hold_queue_status_impl { my $e = shift; my $hold = shift; - # The holds queue is defined as the set of holds that share at - # least one potential copy with the context hold + # The holds queue is defined as the distinct set of holds that share at + # least one potential copy with the context hold, plus any holds that + # share the same hold type and target. The latter part exists to + # accomodate holds that currently have no potential copies my $q_holds = $e->json_query({ - select => { - ahcm => ['hold'], - # fetch request_time since it's in the order_by and we're asking for distinct values - ahr => ['request_time'] + + # fetch request_time since it's in the order_by and we're asking for distinct values + select => {ahr => ['id', 'request_time']}, + + from => { + ahr => { + ahcm => {type => 'left'} # there may be no copy maps + } }, - from => {ahcm => 'ahr'}, order_by => {ahr => ['request_time']}, distinct => 1, where => { - target_copy => { - in => { - select => {ahcm => ['target_copy']}, - from => 'ahcm', - where => {hold => $hold->id} - } - } + '-or' => [ + { + '+ahcm' => { + target_copy => { + in => { + select => {ahcm => ['target_copy']}, + from => 'ahcm', + where => {hold => $hold->id} + } + } + } + }, + { + '+ahr' => { + hold_type => $hold->hold_type, + target => $hold->target + } + } + ] }, }); my $qpos = 1; for my $h (@$q_holds) { - last if $h->{hold} == $hold->id; + last if $h->{id} == $hold->id; $qpos++; } -- 2.11.0