madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22470: LJSUP-12836: Create additional notificat...

Committer: sbelyaev
LJSUP-12836: Create additional notification on day of birthday
U   trunk/bin/worker/birthday-notify
Modified: trunk/bin/worker/birthday-notify
===================================================================
--- trunk/bin/worker/birthday-notify	2012-07-18 14:24:09 UTC (rev 22469)
+++ trunk/bin/worker/birthday-notify	2012-07-19 08:21:01 UTC (rev 22470)
@@ -105,7 +105,14 @@
     # have already passed (eg, worker backlog)
     my $bdays = LJ::User->next_birthdays(@uids);
 
+    my $purge_is_needed = 0;
+
     foreach my $u (values %$us) {
+        unless ($u) {
+            $purge_is_needed = 1;
+            next;
+        }
+
         # don't want to process read-only users (being moved?)
         next if $u->readonly;
 
@@ -134,6 +141,13 @@
         $ct++;
     }
 
+    if ($purge_is_needed) {
+        foreach my $uid (keys %$us) {
+            remove_userid_from_cluster($uid, $working_clusterid)
+                unless $us->{$uid};
+        }
+    }
+
     # return and release our lock as it falls out of scope
 
     return $ct;
@@ -181,6 +195,17 @@
     return @$userids;
 }
 
+sub remove_userid_from_cluster {
+    my ($uid, $cid) = @_;
+    debug("Cleaning up for userid: " . $uid);
+
+    my $dbh = LJ::get_cluster_master($cid)
+        or die "Unable to get cluster reader for cluster: $cid";
+
+    $dbh->do("DELETE FROM birthdays WHERE userid = ?", undef, $uid);
+    die $dbh->errstr if $dbh->err;
+}
+
 sub remove_user_from_cluster {
     my ($u, $cid) = @_;
     debug("Cleaning up for moved user: " . $u->user);

Tags: livejournal, madeon, sbelyaev
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