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

[livejournal] r23064: LJSUP-13287: Mass suspension tool

Committer: amyshkin
LJSUP-13287: Mass suspension tool
U   trunk/cgi-bin/LJ/User.pm
U   trunk/htdocs/admin/statushistory.bml
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-10-08 08:38:42 UTC (rev 23063)
+++ trunk/cgi-bin/LJ/User.pm	2012-10-08 10:55:56 UTC (rev 23064)
@@ -7052,8 +7052,7 @@
 # args: userids
 # returns: hashref with keys ids, values $u refs.
 # </LJFUNC>
-sub load_userids
-{
+sub load_userids {
     my %u;
     LJ::load_userids_multiple([ map { $_ => \$u{$_} } @_ ]);
     return \%u;
@@ -7329,24 +7328,26 @@
 
 sub load_users {
     my @users = @_;
-    
+
     my %need = map {$_ => 1} @users;
 
     ## skip loaded
     my %loaded;
-    foreach my $user (@users){
+
+    foreach my $user ( @users ) {
         if (my $u = $LJ::REQ_CACHE_USER_NAME{$user}) {
             $loaded{$u->userid} = $u;
             delete $need{$u->userid};
         }
     }
 
-    ## username to userid
-    my $uids = LJ::MemCache::get_multi( map {"uidof:$_"} keys %need );
-    my $us = LJ::load_userids( values %$uids );
-    while (my ($k, $v) = each %loaded){
+    ## username to userid and load
+    my $us = LJ::load_userids( LJ::get_userid_multi( keys %need ) );
+
+    while ( my ($k, $v) = each %loaded ) {
         $us->{$k} = $v;
     }
+
     return $us;
 }
 
@@ -10458,8 +10459,7 @@
 # des-user: Username whose userid to look up.
 # returns: Userid, or 0 if invalid user.
 # </LJFUNC>
-sub get_userid
-{
+sub get_userid {
     &nodb;
     my $user = shift;
 
@@ -10491,6 +10491,17 @@
     return ($userid+0);
 }
 
+sub get_userid_multi {
+    my($users) = @_;
+    my @res;
+
+    for my $user ( @$users ) {
+        push @res, LJ::get_userid( $user );
+    }
+
+    return @res;
+}
+
 # <LJFUNC>
 # name: LJ::want_userid
 # des: Returns userid when passed either userid or the user hash. Useful to functions that

Modified: trunk/htdocs/admin/statushistory.bml
===================================================================
--- trunk/htdocs/admin/statushistory.bml	2012-10-08 08:38:42 UTC (rev 23063)
+++ trunk/htdocs/admin/statushistory.bml	2012-10-08 10:55:56 UTC (rev 23064)
@@ -60,20 +60,30 @@
     }
     my $flow = $FORM{'flow'} eq 'asc' ? 'ASC' : 'DESC';
 
-    my $sth = $dbr->prepare("SELECT u.user, ua.user AS admin, s.shtype, s.shdate, s.notes " .
-                            "FROM statushistory s " .
-                            "LEFT JOIN useridmap ua ON s.adminid=ua.userid " .
-                            "LEFT JOIN useridmap u ON s.userid=u.userid " .
-                            $where .
-                            "ORDER BY $orderby $flow LIMIT 1000");
+        my $sql = qq~
+        SELECT u.user,
+               ua.user AS admin,
+               s.shtype,
+               s.shdate,
+               s.notes
+          FROM statushistory s
+     LEFT JOIN useridmap ua ON s.adminid=ua.userid
+     LEFT JOIN useridmap u ON s.userid=u.userid
+        $where
+      ORDER BY $orderby $flow
+         LIMIT 1000~;
+
+    my $sth = $dbr->prepare($sql);
     $sth->execute;
     return $dbr->errstr if $dbr->err;
 
     # column headings w/ sort links
     $ret .= "<p><b>Query:";
+
     foreach (qw(user admin type)) {
         $ret .= "&nbsp;&nbsp;$_=" . LJ::eall($FORM{$_}) if $FORM{$_}
     }
+
     $ret .= "</b></p>\n";
     $ret .= "<table border='1' cellpadding='5' width='100%'>\n<tr>";
     foreach (qw(user admin shtype shdate notes)) {
@@ -85,6 +95,7 @@
 
     # query built above
     my $ct = 0;
+
     while (my $hist = $sth->fetchrow_hashref) {
         # see if they can see this item: either they have unarged historyview or
         # they have historyview:shtype

Tags: amyshkin, bml, 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