madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22819: 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 14:32:00 UTC (rev 22818)
+++ trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-09-05 14:52:20 UTC (rev 22819)
@@ -84,7 +84,7 @@
     my @entries;
 
     my $time = time() - 60*5;
-    my $list = $dbh->selectall_arrayref( "SELECT journalid, delayedid, posterid " .
+    my $list = $dbh->selectall_arrayref( "SELECT journalid, delayedid, posterid, lastposttry " .
                                          "FROM delayedlog2 ".
                                          "WHERE posttime <= NOW() AND " . 
                                          "finaltime IS NULL AND " . 
@@ -97,7 +97,8 @@
         push @entries, LJ::DelayedEntry->load_data($dbh,
                                                    { journalid  => $tuple->[0],
                                                      delayed_id => $tuple->[1],
-                                                     posterid   => $tuple->[2]} );
+                                                     posterid   => $tuple->[2],
+                                                     lastpostry => $tuple->[3],} );
     }
 
     return undef if !scalar @entries;
@@ -172,14 +173,8 @@
                  return;
             }
 
-            foreach my $entry (@$entries) {
-                print "mark entry as posted:\n" .
-                      "\tdelayed id = " . $entry->delayedid .
-                      "\tpost date " . $entry->posterid . "\n" if $verbose;
+            @$entries = grep { $_->work_in_progress() } @$entries;
 
-                $entry->work_in_progress();
-            }
-
             $lock->unlock;
  
             foreach my $entry (@$entries) {

Modified: trunk/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry.pm	2012-09-05 14:32:00 UTC (rev 22818)
+++ trunk/cgi-bin/LJ/DelayedEntry.pm	2012-09-05 14:52:20 UTC (rev 22819)
@@ -254,15 +254,16 @@
     my ($self) = @_;
 
     my $time = time();
-    $self->journal->do( "UPDATE delayedlog2 SET ".
-                        "lastposttry=? " .
-                        "WHERE delayedid = ? AND " .
-                        "journalid = ?",
-                        undef,
-                        $time,
-                        $self->delayedid,
-                        $self->journalid );
-
+    return $self->journal->do( "UPDATE delayedlog2 SET ".
+                               "lastposttry=? " .
+                               "WHERE delayedid = ? AND " .
+                               "journalid = ? AND " .
+                               "lastposttry = ?" ,
+                               undef,
+                               $time,
+                               $self->delayedid,
+                               $self->journalid,
+                               $self->{lastposttry}, );
 }
 
 sub convert_from_data {
@@ -718,6 +719,7 @@
     $self->{poster}     = LJ::want_user($opts->{posterid});
     $self->{data}       = __deserialize($data_ser);
     $self->{posttime}   = __get_datetime($self->{data});
+    $self->{lastposttry} = $opts->{lastposttry};
 
     return $self;
 }

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