Recalls: guard against issuing a recall multiple times
authorDan Scott <dscott@laurentian.ca>
Tue, 13 Nov 2012 16:55:45 +0000 (11:55 -0500)
committerDan Scott <dscott@laurentian.ca>
Tue, 13 Nov 2012 16:55:45 +0000 (11:55 -0500)
We provided no protection against a recall being issued multiple times;
if we have a return date that matches the due date of a potential target
circ, then use that as a flag to not issue the recall.

(Possibly should check for due dates <= instead of just exactly equal)?

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm

index 5f7c0cf..2509365 100644 (file)
@@ -1607,9 +1607,19 @@ sub process_recall {
 
     my $return_date = DateTime->now(time_zone => 'local')->add(seconds => interval_to_seconds($return_interval))->iso8601();
 
+    # If we find a copy that matches our return date; this is a flag that we've
+    # already issued a recall notice
+    my $circs = [ action::circulation->search_where(
+        { target_copy => \@copy_ids, checkin_time => undef, due_date => { '=' => $return_date } },
+        { order_by => 'due_date ASC' }
+    )];
+    if (scalar(@$circs)) {
+        return;
+    }
+
     # Iterate over the checked-out copies to find a copy with a
     # loan period longer than the recall threshold:
-    my $circs = [ action::circulation->search_where(
+    $circs = [ action::circulation->search_where(
         { target_copy => \@copy_ids, checkin_time => undef, duration => { '>' => $recall_threshold } },
         { order_by => 'due_date ASC' }
     )];