vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r23306: LJSV-2476: Makes birthday notifications ...

Committer: vad
LJSV-2476: Makes birthday notifications to appear evenly throughout the hour
U   trunk/bin/worker/birthday-notify
Modified: trunk/bin/worker/birthday-notify
===================================================================
--- trunk/bin/worker/birthday-notify	2012-11-14 13:11:47 UTC (rev 23305)
+++ trunk/bin/worker/birthday-notify	2012-11-14 14:27:43 UTC (rev 23306)
@@ -135,14 +135,19 @@
         next unless $u->should_fire_birthday_notif;
 
         debug("Firing off notification for " . $u->user);
-        LJ::Event::Birthday->new($u)->fire;
 
+        # add a random dealy to prevent one-time occurrence of thousands of jobs,
+        # it makes jobs to appear evenly throughout the hour
+        my $delay = int rand 3600;
+
+        LJ::Event::Birthday->new($u, time + $delay)->fire;
+
         my $notify = DateTime->from_epoch( epoch => $bdays->{$u->id} );
         $notify->set_second(0);
         $notify->set_minute(0);
         $notify->set_hour($notify->hour % 12);
 
-        LJ::Event::Birthday->new($u, $notify->epoch)->fire;
+        LJ::Event::Birthday->new($u, $notify->epoch + $delay)->fire;
         $ct++;
     }
 

Tags: livejournal, vad, vadvs
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments