madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22364: LJSUP-12772: Support patch for db update...

Committer: sbelyaev
LJSUP-12772: Support patch for db update (r94 adding new row into repost2)
U   trunk/cgi-bin/LJ/Entry/Repost.pm
Modified: trunk/cgi-bin/LJ/Entry/Repost.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry/Repost.pm	2012-07-02 11:10:27 UTC (rev 22363)
+++ trunk/cgi-bin/LJ/Entry/Repost.pm	2012-07-02 12:05:33 UTC (rev 22364)
@@ -72,11 +72,15 @@
 
     my $journalid = $u->userid;
 
-    $u->do('INSERT INTO repost2(journalid,
-                                jitemid,
-                                reposterid,
-                                reposted_jitemid,
-                                repost_time)  VALUES(?,?,?,?, NOW())',
+    my $query = 'INSERT INTO repost2(journalid,
+                                    jitemid,
+                                    reposterid,
+                                    reposted_jitemid';
+    $query .= LJ::is_enabled('repost2_with_time') ? 
+                            ',repost_time) VALUES(?,?,?,?,NOW())' :
+                            ') VALUES(?,?,?,?)'; 
+                                    
+    $u->do( $query,
             undef,
             $u->userid,
             $itemid,
@@ -231,12 +235,11 @@
     my $subkey = "$journalid:$jitemid";
     my $memcached_key_list = "reposters_keys_list:$subkey";
 
-    my ($keys_list) = LJ::MemCache::get($memcached_key_list);
-    if ($keys_list) {
+    my ($keys_list) = LJ::MemCache::get($memcached_key_list) ;
+    if (length $keys_list) {
         my @keys = split(/:/, $keys_list);
         foreach my $key (@keys) {
             my $memcache_key = "reposters_list_chunk:$subkey:$key";
-
             LJ::MemCache::delete($memcache_key);
         }
     }
@@ -253,7 +256,7 @@
     if ($lastrequest) {
         LJ::MemCache::append($memcache_keys_list,":$lastrequest");
     } else {
-        LJ::MemCache::add($memcache_keys_list, "$lastrequest", REPOST_KEYS_EXPIRING);
+        LJ::MemCache::set($memcache_keys_list, "$lastrequest", REPOST_KEYS_EXPIRING);
     }
     
     my $serialized = LJ::JSON->to_json( $data );
@@ -267,6 +270,7 @@
 
     my $data;
     my $reposters = LJ::MemCache::get($memcache_key);
+
     if ($reposters) {
         eval {
             $data = LJ::JSON->from_json($reposters);
@@ -286,11 +290,14 @@
         or die "get cluster for journal failed";
 
     my $final_limit = REPOST_USERS_LIST_LIMIT + 1;
-    my $reposters = $dbcr->selectcol_arrayref( 'SELECT reposterid ' .
-                                               'FROM repost2 ' .
-                                               'WHERE journalid = ? AND jitemid = ? ' . 
-                                               'ORDER BY repost_time ' .
-                                               "LIMIT $lastrequest, $final_limit",
+    my $query_reposters = 'SELECT reposterid ' .
+                          'FROM repost2 ' .
+                          'WHERE journalid = ? AND jitemid = ? ';
+
+    $query_reposters .=  LJ::is_enabled('repost2_with_time') ? 'ORDER BY repost_time ' :  '';
+    $query_reposters .= "LIMIT $lastrequest, $final_limit";
+
+    my $reposters = $dbcr->selectcol_arrayref( $query_reposters,
                                                undef,
                                                $u->userid,
                                                $jitemid,);

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