[dw-free] Enhancements to "find users with similar interests"
[commit: http://hg.dwscoalition.org/dw-free/rev/b6c639a8bb2d]
http://bugs.dwscoalition.org/show_bug.cgi?id=2018
Use methods, instead of querying SQL. Cleaner, and lets us take advantage of
caching.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2018
Use methods, instead of querying SQL. Cleaner, and lets us take advantage of
caching.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/Controller/Search/Interests.pm
-------------------------------------------------------------------------------- diff -r c88e621da04a -r b6c639a8bb2d cgi-bin/DW/Controller/Search/Interests.pm --- a/cgi-bin/DW/Controller/Search/Interests.pm Mon Feb 07 15:17:09 2011 +0800 +++ b/cgi-bin/DW/Controller/Search/Interests.pm Tue Feb 08 20:47:29 2011 +0800 @@ -166,20 +166,16 @@ sub interest_handler { { user => $u->ljuser_display } ) unless @matches; - # prepare userid => username hash - $sth = $dbr->prepare( "SELECT userid, user FROM useridmap WHERE userid IN (" . - join( ",", @matches ) . ")" ); - $sth->execute; - my %username; - while ( my ( $id, $name ) = $sth->fetchrow_array ) { - $username{$id} = $name; - } + # load user objects + my $users = LJ::load_userids( @matches ); my $count = 1; my $data = []; foreach my $uid ( @matches ) { + my $match_u = $users->{$uid}; + next unless $match_u && $match_u->is_visible; push @$data, { count => $count++, - user => LJ::ljuser( $username{$uid} ), + user => $match_u->ljuser_display, magic => sprintf( "%.3f", $magic{$uid} ) }; } $rv->{findsim_u} = $u; --------------------------------------------------------------------------------