sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[livejournal] r23433: LJSUP-14123: Change what is displayed in...

Committer: vtroitsky
LJSUP-14123: Change what is displayed in the column 'Last update'
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-12-06 11:48:00 UTC (rev 23432)
+++ trunk/cgi-bin/LJ/User.pm	2012-12-06 12:36:46 UTC (rev 23433)
@@ -3924,6 +3924,41 @@
     return $timeupdate->{$u->id};
 }
 
+# when was last time new public entry was created
+sub last_public_entry_time {
+    my $u = shift;
+    return $u->{_cache_last_public_time} if $u->{_cache_last_public_time};
+
+    my $memkey = [$u->id, "lpt:" . $u->id];
+    my $lastpublic = LJ::MemCache::get($memkey);
+    if ($lastpublic) {
+        $u->{_cache_last_public_time} = $lastpublic;
+        return $lastpublic;
+    }
+
+    my $err;
+    my @entries = LJ::get_recent_items({ 
+                            'userid'    => $u->userid,
+                            'clusterid' => $u->clusterid,
+                            'skip'      => 0,
+                            'itemshow'  => 1,
+                            'err'       => \$err,
+                            });
+
+    $lastpublic = 0;
+    if ($err) {
+        warn "Error loading recent_entries: $err";
+    } else {
+        my $entry = shift @entries;
+        $lastpublic = LJ::TimeUtil->mysqldate_to_time($entry->{logtime}, 0);
+    }
+
+    $u->{_cache_last_public_time} = $lastpublic;
+    LJ::MemCache::set($memkey, $lastpublic, 60*3);
+
+    return $lastpublic;
+}
+
 # can this user use ESN?
 sub can_use_esn {
     my $u = shift;

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