holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[livejournal] r22493: 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-25 07:31:59 UTC (rev 22492)
+++ trunk/cgi-bin/LJ/User.pm	2012-07-25 08:31:31 UTC (rev 22493)
@@ -2882,18 +2882,14 @@
     my ($u) = @_;
 
     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;
-        }
-    } else {
+    if ($soc_capital) {
         return $soc_capital;
+    } else {  
+        $soc_capital = LJ::PersonalStats::DB->fetch_raw('ratings', {func => 'get_authority', journal_id => $u->userid}); 
+        my $value = $soc_capital ? int($soc_capital->{result}->{authority}/1000) : 0;
+        LJ::MemCache::set( $u->user."_soc_cap", $value, 60*60);
+        return $value;
     }
-
-    return 0;
 }
 
 # <LJFUNC>

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