holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[livejournal] r22490: LJSUP-13036: Create subroutine for get s...

Committer: akanashin
LJSUP-13036: Create subroutine for get social capital by user
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-07-24 11:26:06 UTC (rev 22489)
+++ trunk/cgi-bin/LJ/User.pm	2012-07-24 13:38:20 UTC (rev 22490)
@@ -2881,10 +2881,14 @@
 sub get_social_capital {
     my ($u) = @_;
 
-    my $soc_capital = LJ::PersonalStats::DB->fetch_raw('ratings', {func => 'get_authority', journal_id => $u->userid}); 
-
-    if ($soc_capital) {
-        return int($soc_capital->{result}->{authority}/1000);
+    my $soc_capital = LJ::MemCache::get( $u->user."_soc_cap" );
+    unless ($soc_capital) {
+        $soc_capital = LJ::PersonalStats::DB->fetch_raw('ratings', {func => 'get_authority', journal_id => $u->userid}); 
+        if ($soc_capital) {
+            my $value = int($soc_capital->{result}->{authority}/1000);
+            LJ::MemCache::set( $u->user."_soc_cap", $value, 60*60);
+            return $value;
+        }
     }
 
     return 0;

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