Committer: akanashin
LJSUP-13036: Create subroutine for get social capital by userU 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;