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:52 pm

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

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

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

Add the ability to exclude users in your circle from interests results.

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 b6c639a8bb2d -r a3e03737f6ff cgi-bin/DW/Controller/Search/Interests.pm
--- a/cgi-bin/DW/Controller/Search/Interests.pm	Tue Feb 08 20:47:29 2011 +0800
+++ b/cgi-bin/DW/Controller/Search/Interests.pm	Tue Feb 08 20:51:49 2011 +0800
@@ -162,24 +162,35 @@ sub interest_handler {
         my @matches = sort { $magic{$b} <=> $magic{$a} } keys %magic;
         @matches = @matches[ 0 .. ( $maxinterests - 1 ) ]
             if scalar( @matches ) > $maxinterests;
-        return error_ml( 'interests.findsim_do.nomatch',
-                         { user => $u->ljuser_display } )
-            unless @matches;
 
         # load user objects
         my $users = LJ::load_userids( @matches );
 
+        my $nocircle = $remote && $args->{nocircle};
         my $count = 1;
         my $data = [];
         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 );
+            }
             push @$data, { count => $count++,
                            user  => $match_u->ljuser_display,
                            magic => sprintf( "%.3f", $magic{$uid} ) };
         }
+
+        return error_ml( 'interests.findsim_do.nomatch',
+                         { user => $u->ljuser_display } )
+            unless @$data;
+
         $rv->{findsim_u} = $u;
         $rv->{findsim_data} = $data;
+        $rv->{nocircle} = $nocircle;
+        $rv->{circle_link} =
+            LJ::page_change_getargs( nocircle => $nocircle ? '' : 1 );
+
         return DW::Template->render_template( 'interests/findsim.tt', $rv );
     }
 
diff -r b6c639a8bb2d -r a3e03737f6ff views/interests/findsim.tt
--- a/views/interests/findsim.tt	Tue Feb 08 20:47:29 2011 +0800
+++ b/views/interests/findsim.tt	Tue Feb 08 20:51:49 2011 +0800
@@ -22,8 +22,17 @@
 
 [%- sections.title='.title' | ml -%]
 
-<h1>[% '.findsim_do.similar.head' | ml %]</h1>
-<p>[% ".findsim_do.similar.text" | ml(user = findsim_u.ljuser_display) %]</p>
+<h1>[% '.head' | ml %]</h1>
+[%- IF remote -%]
+    <p>
+    [%- IF nocircle -%]
+        [%- '.circle.include' | ml(aopts = circle_link) -%]
+    [%- ELSE -%]
+        [%- '.circle.exclude' | ml(aopts = circle_link) -%]
+    [%- END -%]
+    </p>
+[%- END -%]
+<p>[% '.text' | ml(user = findsim_u.ljuser_display) %]</p>
 <p><table cellpadding='3'><thead><tr valign='bottom'>
     <th>#</th>
     <th width='250'>[% 'username' | ml %]</th>
diff -r b6c639a8bb2d -r a3e03737f6ff views/interests/findsim.tt.text
--- a/views/interests/findsim.tt.text	Tue Feb 08 20:47:29 2011 +0800
+++ b/views/interests/findsim.tt.text	Tue Feb 08 20:51:49 2011 +0800
@@ -1,12 +1,16 @@
 ;; -*- coding: utf-8 -*-
+.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>
+
 .findsim_do.magic=Magic<br />Index
 
 .findsim_do.magic.head=What's this Magic Index all about?
 
 .findsim_do.magic.text=We compute a magic index for each matching account. A magic index is a weighting of two factors: the raw number of shared interests and extra points for shared uncommon interests.
 
-.findsim_do.similar.head=Similar People
+.head=Similar Accounts
 
-.findsim_do.similar.text=The following people are the most related to [[user]]
+.text=The following accounts have interests closely related to those of [[user]]:
 
 .title=Interests
--------------------------------------------------------------------------------

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