[freeside-commits] freeside/FS/FS cust_main_Mixin.pm,1.9,1.10

Mark Wells mark at wavetail.420.am
Fri Oct 1 17:32:23 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv11690/FS/FS

Modified Files:
	cust_main_Mixin.pm 
Log Message:
avoid sending duplicate notices from package search, RT#10103

Index: cust_main_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main_Mixin.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -d -r1.9 -r1.10
--- cust_main_Mixin.pm	17 Sep 2010 18:07:07 -0000	1.9
+++ cust_main_Mixin.pm	2 Oct 2010 00:32:21 -0000	1.10
@@ -423,7 +423,9 @@
 
   my( $num, $last, $min_sec ) = (0, time, 5); #progresbar foo
   my @retry_jobs = ();
+  my $dups = 0;
   my $success = 0;
+  my %sent_to = ();
 
   #eventually order+limit magic to reduce memory use?
   foreach my $obj ( qsearch($sql_query) ) {
@@ -444,8 +446,20 @@
       next; # unlinked object; nothing else we can do
     }
     
+    if( $sent_to{$cust_main->custnum} ) {
+      # avoid duplicates
+      $dups++;
+      next;
+    }
+
+    $sent_to{$cust_main->custnum} = 1;
+    
     if ( $msg_template ) {
       # XXX add support for other context objects?
+      # If we do that, handling of "duplicates" will 
+      # have to be smarter.  Currently we limit to 
+      # one message per custnum because they'd all
+      # be identical.
       @message = $msg_template->prepare( 'cust_main' => $cust_main );
     }
     else {
@@ -494,7 +508,7 @@
   if(@retry_jobs) {
     # fail the job, but with a status message that makes it clear
     # something was sent.
-    return "Sent $success, failed ".scalar(@retry_jobs).". Failed attempts placed in job queue.\n";
+    return "Sent $success, skipped $dups duplicate(s), failed ".scalar(@retry_jobs).". Failed attempts placed in job queue.\n";
   }
 
   return '';



More information about the freeside-commits mailing list