holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[ljcom] r12568: LJSUP-13192: Additional development of l...

Committer: akanashin
LJSUP-13192: Additional development of latest.bml
U   trunk/bin/worker/latest-posts
Modified: trunk/bin/worker/latest-posts
===================================================================
--- trunk/bin/worker/latest-posts	2012-08-28 15:27:24 UTC (rev 12567)
+++ trunk/bin/worker/latest-posts	2012-08-29 06:34:36 UTC (rev 12568)
@@ -16,14 +16,18 @@
     my $args = $job->arg;
 
     $LJ::CACHE_RECENTPOSTS_CHANGES = 0;
-    $LJ::CACHE_RECENTPOSTS ||= LJ::MemCache::get("blob:ljcom_latestposts2") || [];
+    $LJ::CACHE_RECENTPOSTS_CYR    ||= LJ::MemCache::get("blob:ljcom_latestposts_cyr") || [];
+    $LJ::CACHE_RECENTPOSTS_NONCYR ||= LJ::MemCache::get("blob:ljcom_latestposts_noncyr") || [];
 
     $LJ::CACHE_RECENTIMG_CHANGES = 0;
     $LJ::CACHE_RECENTIMG ||= LJ::MemCache::get("blob:ljcom_latestimg") || [];
 
-    my $recent = $LJ::CACHE_RECENTPOSTS;
     my $uj = LJ::load_userid($args->{'journalid'});
     my $up = LJ::load_userid($args->{'posterid'});
+
+    my $is_sup = LJ::SUP->is_sup_enabled($up);
+    my $recent = $is_sup ? $LJ::CACHE_RECENTPOSTS_CYR : $LJ::CACHE_RECENTPOSTS_NONCYR;
+
     unless ($uj->{'statusvis'} eq "V" && $up->{'statusvis'} eq "V") {
         $job->completed;
         return;
@@ -59,13 +63,15 @@
         $LJ::CACHE_RECENTIMG_CHANGES++;
     }
 
-    _post_work();
+    _post_work($is_sup);
     $job->completed;
 }
 
 sub _post_work {
+    my $is_sup = shift;
     return unless $LJ::CACHE_RECENTPOSTS_CHANGES;
-    my $recent = $LJ::CACHE_RECENTPOSTS;
+
+    my $recent = $is_sup ? $LJ::CACHE_RECENTPOSTS_CYR : $LJ::CACHE_RECENTPOSTS_NONCYR;
     my $rimg = $LJ::CACHE_RECENTIMG;
 
     my $show_max = $LJ::STATS_LATESTPOSTS_MAX || 1000;
@@ -73,17 +79,14 @@
     @$recent = sort { $b->{'timepost'} <=> $a->{'timepost'}  } @$recent;
     splice(@$recent, $show_max) if @$recent > $show_max;
 
-    LJ::MemCache::set("blob:ljcom_latestposts2", $recent);
+    my $memkey = $is_sup ? "blob:ljcom_latestposts_cyr" : "blob:ljcom_latestposts_noncyr";
+    LJ::MemCache::set($memkey, $recent);
 
     if ($LJ::CACHE_RECENTIMG_CHANGES) {
         my $size = @$rimg;
         splice(@$rimg, 0, $size - $show_max) if $size > $show_max;
         LJ::MemCache::set("blob:ljcom_latestimg", $rimg);
     }
-    LJ::MemCache::set("blob:ljcom_latestposts_stats",
-                      [ scalar(@$recent),
-                        $recent->[0]->{timepost},
-                        $recent->[-1]->{timepost} ]);
 }
 
 sub keep_exit_status_for { 0 }

Tags: akanashin, holyandrew, ljcom
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