fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-02-08 12:55 pm

[dw-free] Enhancements to "find users with similar interests"

[commit: http://hg.dwscoalition.org/dw-free/rev/7acf6200abb8]

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

Split up results by journal type.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/DW/Controller/Search/Interests.pm
  • views/interests/findsim.tt
  • views/interests/findsim.tt.text
--------------------------------------------------------------------------------
diff -r a3e03737f6ff -r 7acf6200abb8 cgi-bin/DW/Controller/Search/Interests.pm
--- a/cgi-bin/DW/Controller/Search/Interests.pm	Tue Feb 08 20:51:49 2011 +0800
+++ b/cgi-bin/DW/Controller/Search/Interests.pm	Tue Feb 08 20:54:56 2011 +0800
@@ -167,25 +167,29 @@ sub interest_handler {
         my $users = LJ::load_userids( @matches );
 
         my $nocircle = $remote && $args->{nocircle};
-        my $count = 1;
-        my $data = [];
+        my $count = { P => 0, C => 0, I => 0 };
+        my $data = { P => [], C => [], I => [] };
         foreach my $uid ( @matches ) {
             my $match_u = $users->{$uid};
             next unless $match_u && $match_u->is_visible;
             if ( $nocircle ) {
                 next if $remote->watches( $match_u );
-                next if $remote->trusts( $match_u );
+                next if $match_u->is_person && $remote->trusts( $match_u );
+                next if $match_u->is_comm && $remote->member_of( $match_u );
             }
-            push @$data, { count => $count++,
-                           user  => $match_u->ljuser_display,
-                           magic => sprintf( "%.3f", $magic{$uid} ) };
+            my $j = $match_u->journaltype;
+            push @{ $data->{$j} },
+                    { count => ++$count->{$j},
+                      user  => $match_u->ljuser_display,
+                      magic => sprintf( "%.3f", $magic{$uid} ) };
         }
 
         return error_ml( 'interests.findsim_do.nomatch',
                          { user => $u->ljuser_display } )
-            unless @$data;
+            unless grep { $_ } values %$count;
 
         $rv->{findsim_u} = $u;
+        $rv->{findsim_count} = $count;
         $rv->{findsim_data} = $data;
         $rv->{nocircle} = $nocircle;
         $rv->{circle_link} =
diff -r a3e03737f6ff -r 7acf6200abb8 views/interests/findsim.tt
--- a/views/interests/findsim.tt	Tue Feb 08 20:51:49 2011 +0800
+++ b/views/interests/findsim.tt	Tue Feb 08 20:54:56 2011 +0800
@@ -13,8 +13,7 @@
 
 [%- sections.head = BLOCK %]
 <style type='text/css'>
-    div.tagcloud a { text-decoration: none; }
-    ul.contentlist li { padding-bottom: 3px; }
+    .accountlist { padding-bottom: 3em; }
 </style>
 [% END -%]
 
@@ -33,18 +32,60 @@
     </p>
 [%- END -%]
 <p>[% '.text' | ml(user = findsim_u.ljuser_display) %]</p>
-<p><table cellpadding='3'><thead><tr valign='bottom'>
+
+[%- IF findsim_count.P -%]
+<div class="accountlist">
+<h2>[% '.accounts.person' | ml %]</h2>
+<table cellpadding='3'><thead><tr valign='bottom'>
     <th>#</th>
     <th width='250'>[% 'username' | ml %]</th>
     <th>[% '.findsim_do.magic' | ml %]</th>
 </tr></thead>
-[%- FOREACH findsim_data -%]
+[%- FOREACH findsim_data.P -%]
     <tr>
         <td>[% count %]</td>
         <td>[% user %]</td>
         <td>[% magic %]</td>
     </tr>
 [%- END -%]
-</table></p>
+</table></div>
+[%- END -%]
+
+[%- IF findsim_count.C -%]
+<div class="accountlist">
+<h2>[% '.accounts.comm' | ml %]</h2>
+<table cellpadding='3'><thead><tr valign='bottom'>
+    <th>#</th>
+    <th width='250'>[% 'username' | ml %]</th>
+    <th>[% '.findsim_do.magic' | ml %]</th>
+</tr></thead>
+[%- FOREACH findsim_data.C -%]
+    <tr>
+        <td>[% count %]</td>
+        <td>[% user %]</td>
+        <td>[% magic %]</td>
+    </tr>
+[%- END -%]
+</table></div>
+[%- END -%]
+
+[%- IF findsim_count.I -%]
+<div class="accountlist">
+<h2>[% '.accounts.id' | ml %]</h2>
+<table cellpadding='3'><thead><tr valign='bottom'>
+    <th>#</th>
+    <th width='250'>[% 'username' | ml %]</th>
+    <th>[% '.findsim_do.magic' | ml %]</th>
+</tr></thead>
+[%- FOREACH findsim_data.I -%]
+    <tr>
+        <td>[% count %]</td>
+        <td>[% user %]</td>
+        <td>[% magic %]</td>
+    </tr>
+[%- END -%]
+</table></div>
+[%- END -%]
+
 <h1>[% '.findsim_do.magic.head' | ml %]</h1>
 <p> [% '.findsim_do.magic.text' | ml %]</p>
diff -r a3e03737f6ff -r 7acf6200abb8 views/interests/findsim.tt.text
--- a/views/interests/findsim.tt.text	Tue Feb 08 20:51:49 2011 +0800
+++ b/views/interests/findsim.tt.text	Tue Feb 08 20:54:56 2011 +0800
@@ -1,4 +1,10 @@
 ;; -*- coding: utf-8 -*-
+.accounts.comm=Community Accounts
+
+.accounts.id=OpenID Accounts
+
+.accounts.person=Personal Accounts
+
 .circle.exclude=This listing includes accounts you already subscribe to. <a href="[[aopts]]">Exclude users in your circle?</a>
 
 .circle.include=This listing does not include accounts in your circle. <a href="[[aopts]]">Include them?</a>
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org