[open-ils-commits] r13871 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Aug 18 13:45:53 EDT 2009


Author: erickson
Date: 2009-08-18 13:45:49 -0400 (Tue, 18 Aug 2009)
New Revision: 13871

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Log:
updated hold queue position code to consider all hold types that share a common potential copy

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2009-08-18 17:44:53 UTC (rev 13870)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2009-08-18 17:45:49 UTC (rev 13871)
@@ -786,21 +786,31 @@
     my $e = shift;
     my $hold = shift;
 
-    my $hold_ids = $e->search_action_hold_request(
-        [
-            {   target => $hold->target, 
-                hold_type => $hold->hold_type,
-                cancel_time => undef,
-                fulfillment_time => undef
-            },
-            {order_by => {ahr => 'request_time asc'}}
-        ], 
-        {idlist => 1} 
-    );
+    # The holds queue is defined as the set of holds that share at 
+    # least one potential copy with the context hold
+    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']
+        },
+        from => {ahcm => 'ahr'},
+        order_by => {ahr => ['request_time']},
+        distinct => 1,
+        where => {
+            target_copy => {
+                in => {
+                    select => {ahcm => ['target_copy']},
+                    from => 'ahcm',
+                    where => {hold => $hold->id}
+                } 
+            } 
+        }, 
+    });
 
     my $qpos = 1;
-    for my $hid (@$hold_ids) {
-        last if $hid == $hold->id;
+    for my $h (@$q_holds) {
+        last if $h->{hold} == $hold->id;
         $qpos++;
     }
 
@@ -816,7 +826,7 @@
     my $estimated_wait = $qpos * ($default_hold_interval / $num_potentials) if $default_hold_interval;
 
     return {
-        total_holds => scalar(@$hold_ids),
+        total_holds => scalar(@$q_holds),
         queue_position => $qpos,
         potential_copies => $num_potentials,
         status => _hold_status($e, $hold),



More information about the open-ils-commits mailing list