JBAS-2005 Hold queue pos API uses rhrr
authorBill Erickson <berickxx@gmail.com>
Tue, 27 Mar 2018 21:53:29 +0000 (17:53 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Consistent with BC hold queue pos function, we now determine the hold
queue position by comparing holds that target the same bib.  Uses the
newly materialized (as of 2.12) reporter.hold_request_record table.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm

index 83a8faa..43f4bbd 100644 (file)
@@ -1373,21 +1373,27 @@ 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
+        #
+        # KCLS JBAS-2005 Pull hold queue position from newly
+        # materialized reporter.hold_request_record grouping
+        # in targeted bib record.
         select => {ahr => ['id', 'cut_in_line', 'request_time']},
         from   => 'ahr',
         where => {
+            fulfillment_time => undef,
+            cancel_time => undef,
             id => { in => {
-                select => { ahcm => ['hold'] },
+                select => { rhrr => ['id'] },
                 from   => {
-                    'ahcm' => {
-                        'ahcm2' => {
-                            'class' => 'ahcm',
-                            'field' => 'target_copy',
-                            'fkey'  => 'target_copy'
+                    'rhrr' => {
+                        'rhrr2' => {
+                            'class' => 'rhrr',
+                            'field' => 'bib_record',
+                            'fkey'  => 'bib_record'
                         }
                     }
                 },
-                where => { '+ahcm2' => { hold => $hold->id } },
+                where => { '+rhrr2' => { id => $hold->id } },
                 distinct => 1
             }}
         },