wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r17935: LJSUP-7610. Need to remove old recent po...

Committer: gprochaev
LJSUP-7610. Need to remove old recent posts from verticals.

U   trunk/bin/maint/clean_caches.pl
Modified: trunk/bin/maint/clean_caches.pl
===================================================================
--- trunk/bin/maint/clean_caches.pl	2010-12-15 05:53:40 UTC (rev 17934)
+++ trunk/bin/maint/clean_caches.pl	2010-12-15 05:57:47 UTC (rev 17935)
@@ -164,6 +164,23 @@
         print "    rows remaining: " . ($xfp_count - $row_ct) . "\n";
     }
 
+    # removing old posts from landing page
+    print "-I- Removing old posts from landing page.\n";
+
+    my $cats = $dbh->selectall_arrayref ("SELECT catid FROM category WHERE vert_id > 0", { Slice => {} });
+    my $for_in = join ",", map { $_->{catid} } @$cats;
+    my $comms = $for_in ? $dbh->selectall_arrayref ("SELECT journalid FROM categoryjournals WHERE catid IN($for_in)", { Slice => {} }) : [];
+    my $cnt_delete = 0;
+    foreach my $comm (@$comms) {
+        my $posts = $dbh->selectall_arrayref ("SELECT jitemid FROM category_recent_posts WHERE journalid = ? ORDER BY timecreate ASC", { Slice => {} }, $comm->{'journalid'});
+        splice @$posts, 0, 30;
+        $cnt_delete += @#{$posts};
+        my $in_to_delete = join ',', map { $_->{jitemid} } @$posts;
+        $dbh->do ("DELETE FROM category_recent_posts WHERE journalid = ? AND jitemid IN ($in_to_delete)", undef, $comm->{'journalid'})
+            if $in_to_delete;
+    }
+    print "    deleted $cnt_delete\n";
+
     LJ::run_hooks('extra_cache_clean');
 };
 

Tags: livejournal, pl, wisest-owl
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