[Rt-commit] r17110 - rt/3.8/trunk/sbin

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Dec 5 05:58:14 EST 2008


Author: sunnavy
Date: Fri Dec  5 05:58:13 2008
New Revision: 17110

Modified:
   rt/3.8/trunk/sbin/rt-email-dashboards.in

Log:
added frequency of week support for dashboard, now we keep track of the lastsent time

Modified: rt/3.8/trunk/sbin/rt-email-dashboards.in
==============================================================================
--- rt/3.8/trunk/sbin/rt-email-dashboards.in	(original)
+++ rt/3.8/trunk/sbin/rt-email-dashboards.in	Fri Dec  5 05:58:13 2008
@@ -158,8 +158,12 @@
             next if $subscription->SubValue('Hour') ne $hour;
 
             # if weekly, correct day of week?
-            if ($subscription->SubValue('Frequency') eq 'weekly') {
+            if ( $subscription->SubValue('Frequency') eq 'weekly' ) {
                 next if $subscription->SubValue('Dow') ne $dow;
+                my $last_sent = $subscription->SubValue('LastSent') || 0;
+                my $fow       = $subscription->SubValue('Fow') || 1;
+                # minus 120s in case of time inaccuracy when running cron
+                next if ( ( $now - $last_sent ) < 7 * 24 * 3600 * $fow - 120); 
             }
 
             # if monthly, correct day of month?
@@ -172,7 +176,13 @@
                  || $user->EmailAddress;
 
         eval { send_dashboard($currentuser, $email, $subscription) };
-        error 'Caught exception: ' . $@ if $@;
+        if ( $@ ) {
+            error 'Caught exception: ' . $@;
+        }
+        else {
+            # update LastSent if dashboard is sent successfully.
+            $subscription->SetSubValues(LastSent => $now) unless $opts{'dryrun'};
+        }
     }
 }
 


More information about the Rt-commit mailing list