Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r20521: LJSUP-10147: Implement abstract interace...

Committer: amyshkin
LJSUP-10147: Implement abstract interace for access to friends relations
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-11-10 04:19:14 UTC (rev 20520)
+++ trunk/cgi-bin/LJ/User.pm	2011-11-10 04:32:56 UTC (rev 20521)
@@ -4543,21 +4543,9 @@
 sub friends_added_count {
     my $u = shift;
 
-    my @friendids = $u->friend_uids;
-    if (@friendids>5_000) {
-        return scalar @friendids;
-    } else {
-        my %initial = ( map { $_ => 1 } @LJ::INITIAL_FRIENDS, @LJ::INITIAL_OPTIONAL_FRIENDS, $u->user );
-        my $count = 0;
-        my $users = LJ::load_userids(@friendids);
-        while(my ($uid, $u) = each %$users) {
-            next unless $u;
-            next if $initial{$u->user};
-            $count++;
-        }
-        # return count of friends who were not initial
-        return $count;
-    }
+    my @friend_ids = $u->friend_uids;
+    my %init_friends_ids = map { $_ => 1 } LJ::get_uids( @LJ::INITIAL_FRIENDS, @LJ::INITIAL_OPTIONAL_FRIENDS, $u->user );
+    return scalar grep { ! $init_friends_ids{$_} } @friend_ids;
 }
 
 sub set_password {
@@ -7682,6 +7670,13 @@
     $cache->{'_email'} = $email;
 }
 
+sub get_uids {
+    my @friends_names = @_;
+    my @ret;
+    push @ret, grep { $_ } map { LJ::load_user($_) } @friends_names;
+    return @ret;
+}
+
 sub set_password {
     my ($userid, $password) = @_;
 

Tags: amyshkin, livejournal, pm, zilogic
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