holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[livejournal] r22475: 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-19 12:12:05 UTC (rev 22474)
+++ trunk/cgi-bin/LJ/User.pm	2012-07-19 12:33:35 UTC (rev 22475)
@@ -33,6 +33,7 @@
 use LJ::User::InfoHistory;
 use LJ::User::PropStorage;
 use LJ::Response::CachedTemplate;
+use LJ::PersonalStats::DB;
 
 # TODO: get rid of Class::Autouse, maybe? it's pretty useless
 # in web context and leads to some nasty bugs otherwise, so probably
@@ -2876,6 +2877,19 @@
     return 1;
 }
 
+# return social capital by user
+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);
+    }
+
+    return 0;
+}
+
 # <LJFUNC>
 # name: LJ::User::activate_userpics
 # des: Sets/unsets userpics as inactive based on account caps.

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