afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-06-12 02:48 pm

[dw-free] Remove $u->get_recommended_communities

[commit: http://hg.dwscoalition.org/dw-free/rev/47d20be3e6da]

http://bugs.dwscoalition.org/show_bug.cgi?id=1299

Remove unused function.

Patch by [staff profile] denise.

Files modified:
  • cgi-bin/ljlib.pl
--------------------------------------------------------------------------------
diff -r 206ca8346bee -r 47d20be3e6da cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Fri Jun 12 13:52:13 2009 +0000
+++ b/cgi-bin/ljlib.pl	Fri Jun 12 14:47:33 2009 +0000
@@ -1788,108 +1788,6 @@ sub can_use_journal
 
 
 # <LJFUNC>
-# name: LJ::get_recommended_communities
-# class:
-# des: Get communities associated with a user.
-# info:
-# args: user, types
-# des-types: The default value for type is 'normal', which indicates a community
-#           is visible and has not been closed. A value of 'new' means the community has
-#           been created in the last 10 days. Last, a value of 'mm' indicates the user
-#           passed in is a maintainer or moderator of the community.
-# returns: array of communities
-# </LJFUNC>
-sub get_recommended_communities {
-    my $u = shift;
-    # Indicates relationship to user, or activity of community
-    my $type = shift() || {};
-    my %comms;
-
-    # Load their friendofs to determine community membership
-    my @ids = LJ::get_friendofs($u);
-    my %fro = %{ LJ::load_userids(@ids) || {} };
-
-    foreach my $ulocal (values %fro) {
-        next unless $ulocal->{'statusvis'} eq 'V';
-        next unless $ulocal->is_community;
-
-        # TODO: This is bad if they belong to a lot of communities,
-        # is a db query to global each call
-        my $ci = LJ::get_community_row($ulocal);
-        next if $ci->{'membership'} eq 'closed';
-
-        # Add to %comms
-        $type->{$ulocal->{userid}} = 'normal';
-        $comms{$ulocal->{userid}} = $ulocal;
-    }
-
-    # Contains timeupdate and timecreate in an array ref
-    my %times;
-    # Get usage information about comms
-    if (%comms) {
-        my $ids = join(',', keys %comms);
-
-        my $dbr = LJ::get_db_reader();
-        my $sth = $dbr->prepare("SELECT UNIX_TIMESTAMP(timeupdate), UNIX_TIMESTAMP(timecreate), userid ".
-                                 "FROM userusage WHERE userid IN ($ids)");
-        $sth->execute;
-
-        while (my @row = $sth->fetchrow_array) {
-            @{$times{$row[2]}} = @row[0,1];
-        }
-    }
-
-    # Prune the list by time last updated and make sure to
-    # display comms created in the past 10 days or where
-    # the inviter is a maint or mod
-    my $over30 = 0;
-    my $now = time();
-    foreach my $commid (sort {$times{$b}->[0] <=> $times{$a}->[0]} keys %comms) {
-        my $comm = $comms{$commid};
-        if ($now - $times{$commid}->[1] <= 86400*10) {
-            $type->{$commid} = 'new';
-            next;
-        }
-
-        my $maintainers = LJ::load_rel_user_cache($commid, 'A') || [];
-        my $moderators  = LJ::load_rel_user_cache($commid, 'M') || [];
-        foreach (@$maintainers, @$moderators) {
-            if ($_ == $u->{userid}) {
-                $type->{$commid} = 'mm';
-                next;
-            }
-        }
-
-        # Once a community over 30 days old is reached
-        # all subsequent communities will be older and can be deleted
-        if ($over30) {
-            delete $comms{$commid};
-            next;
-        } else {
-            if ($now - $times{$commid}->[0] > 86400*30) {
-                delete $comms{$commid};
-                $over30 = 1;
-            }
-        }
-    }
-
-    # If we still have more than 20 comms, delete any with less than
-    # five members
-    if (%comms > 20) {
-        foreach my $comm (values %comms) {
-            next unless $type->{$comm->{userid}} eq 'normal';
-
-            my $ids = LJ::get_friends($comm);
-            if (%$ids < 5) {
-                delete $comms{$comm->{userid}};
-            }
-        }
-    }
-
-    return values %comms;
-}
-
-# <LJFUNC>
 # name: LJ::load_talk_props2
 # class:
 # des:
--------------------------------------------------------------------------------