From: Bill Erickson Date: Wed, 29 Oct 2014 21:05:30 +0000 (-0400) Subject: KMIG-187: Hold Queue Position X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=193de74c986cedefd5cfc159dbac13f444d45585;p=working%2FEvergreen.git KMIG-187: Hold Queue Position Cross-port: bba2c05 --- diff --git a/KCLS/sql/kmig-187.sql b/KCLS/sql/kmig-187.sql new file mode 100644 index 0000000000..0abc9c6f65 --- /dev/null +++ b/KCLS/sql/kmig-187.sql @@ -0,0 +1,12 @@ +CREATE OR REPLACE FUNCTION action.get_hold_queue_status_by_id(INTEGER) +RETURNS TABLE(id INTEGER, cut_in_line BOOLEAN, request_time timestamp with time zone) +AS $$ +WITH holds(holdid) AS +( SELECT acm.hold FROM action.hold_copy_map acm + JOIN action.hold_copy_map acm2 USING(target_copy) + WHERE acm2.hold=$1) + SELECT id, cut_in_line, request_time FROM action.hold_request + WHERE id IN (SELECT holdid FROM holds) + ORDER BY coalesce(cut_in_line, false ) DESC, request_time; +$$ +LANGUAGE SQL STABLE; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index c7a9b9c77c..a1202045d6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -1368,35 +1368,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', - where => { - id => { in => { - select => { ahcm => ['hold'] }, - from => { - 'ahcm' => { - 'ahcm2' => { - 'class' => 'ahcm', - 'field' => 'target_copy', - 'fkey' => 'target_copy' - } - } - }, - where => { '+ahcm2' => { hold => $hold->id } }, - distinct => 1 - }} - }, - order_by => [ - { - "class" => "ahr", - "field" => "cut_in_line", - "transform" => "coalesce", - "params" => [ 0 ], - "direction" => "desc" - }, - { "class" => "ahr", "field" => "request_time" } - ], - distinct => 1 + from => [ "action.get_hold_queue_status_by_id", $hold->id ] }); if (!@$q_holds) { # none? maybe we don't have a map ...