From 32d122c87b20fab0a766a094dd956111b60f6a0b Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 24 Sep 2010 18:13:17 +0000 Subject: [PATCH] Backporting hold queue stats fixes from 17956, 17957 and 17963 git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_2_0@17964 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ/Holds.pm | 56 +++++++++++++--------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 49aac1a91c..2f1969e589 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -1033,11 +1033,7 @@ sub retrieve_hold_queue_status_impl { # fetch cut_in_line and request_time since they're in the order_by # and we're asking for distinct values select => {ahr => ['id', 'cut_in_line', 'request_time']}, - from => { - ahr => { - ahcm => {type => 'left'} # there may be no copy maps - } - }, + from => { ahr => 'ahcm' }, order_by => [ { "class" => "ahr", @@ -1050,28 +1046,42 @@ sub retrieve_hold_queue_status_impl { ], distinct => 1, where => { - '-or' => [ - { - '+ahcm' => { - target_copy => { - in => { - select => {ahcm => ['target_copy']}, - from => 'ahcm', - where => {hold => $hold->id} - } + { + '+ahcm' => { + target_copy => { + in => { + select => {ahcm => ['target_copy']}, + from => 'ahcm', + where => {hold => $hold->id} } - } - }, - { - '+ahr' => { - hold_type => $hold->hold_type, - target => $hold->target - } + } } - ] - }, + } + } }); + if (!@$q_holds) { # none? maybe we don't have a map ... + $q_holds = $e->json_query({ + select => {ahr => ['id', 'cut_in_line', 'request_time']}, + from => 'ahr', + order_by => [ + { + "class" => "ahr", + "field" => "cut_in_line", + "transform" => "coalesce", + "params" => [ 0 ], + "direction" => "desc" + }, + { "class" => "ahr", "field" => "request_time" } + ], + where => { + hold_type => $hold->hold_type, + target => $hold->target + } + }); + } + + my $qpos = 1; for my $h (@$q_holds) { last if $h->{id} == $hold->id; -- 2.11.0