madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22813: LJSUP-10503: duplication of delay posts

Committer: sbelyaev
LJSUP-10503: duplication of delay posts
U   trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm
U   trunk/cgi-bin/LJ/DelayedEntry.pm
Modified: trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-09-05 11:21:04 UTC (rev 22812)
+++ trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-09-05 13:32:26 UTC (rev 22813)
@@ -83,9 +83,13 @@
     my ($dbh, $verbose) = @_;
     my @entries;
 
+    my $time = time() - 60*5;
     my $list = $dbh->selectall_arrayref( "SELECT journalid, delayedid, posterid " .
                                          "FROM delayedlog2 ".
-                                         "WHERE posttime <= NOW() AND finaltime IS NULL LIMIT 1000" );
+                                         "WHERE posttime <= NOW() AND " . 
+                                         "finaltime IS NULL AND " . 
+                                         "(lastposttry <= $time OR lastposttry IS NULL) " . 
+                                         "LIMIT 1000" );
 
     foreach my $tuple (@$list) {
         push @entries, LJ::DelayedEntry->load_data($dbh,
@@ -171,7 +175,7 @@
                       "\tdelayed id = " . $entry->delayedid .
                       "\tpost date " . $entry->posterid . "\n" if $verbose;
 
-                $entry->mark_posted();
+                $entry->work_in_progress();
             }
 
             $lock->unlock;
@@ -188,7 +192,8 @@
 
                     __notify_user(  $entry->poster,
                                     $entry->journal);
-                    
+            
+                    $entry->mark_posted();        
                     next;
                 }
 

Modified: trunk/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry.pm	2012-09-05 11:21:04 UTC (rev 22812)
+++ trunk/cgi-bin/LJ/DelayedEntry.pm	2012-09-05 13:32:26 UTC (rev 22813)
@@ -250,6 +250,21 @@
                         $self->journalid ); 
 }
 
+sub work_in_progress {
+    my ($self) = @_;
+
+    my $time = time();
+    $self->journal->do( "UPDATE delayedlog2 SET ".
+                        "lastposttry=? " .
+                        "WHERE delayedid = ? AND " .
+                        "journalid = ?",
+                        undef,
+                        $time,
+                        $self->delayedid,
+                        $self->journalid );
+
+}
+
 sub convert_from_data {
     my ($self, $req) = @_;
     my $flags = { 'noauth' => 1,

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