fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-12-28 01:27 pm

[dw-free] Search for several interests at once

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

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

Add search by multiple interests to directory.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/Directory/Constraint.pm
  • cgi-bin/LJ/Directory/Constraint/Interest.pm
--------------------------------------------------------------------------------
diff -r dce155b3e09b -r 0429c47708e3 cgi-bin/LJ/Directory/Constraint.pm
--- a/cgi-bin/LJ/Directory/Constraint.pm	Tue Dec 28 21:19:25 2010 +0800
+++ b/cgi-bin/LJ/Directory/Constraint.pm	Tue Dec 28 21:24:15 2010 +0800
@@ -38,7 +38,9 @@ sub constraints_from_formargs {
     foreach my $type (qw(Age Location UpdateTime Interest Trusts TrustedBy Watches WatchedBy MemberOf JournalType)) {
        my $class = "LJ::Directory::Constraint::$type";
        my $con = eval { $class->new_from_formargs($postargs) };
-       if ($con) {
+       if ( ref $con eq 'ARRAY' ) {
+           push @ret, @$con;
+       } elsif ( $con ) {
            push @ret, $con;
        } elsif ($@) {
            warn "Error loading constraint $type: $@";
diff -r dce155b3e09b -r 0429c47708e3 cgi-bin/LJ/Directory/Constraint/Interest.pm
--- a/cgi-bin/LJ/Directory/Constraint/Interest.pm	Tue Dec 28 21:19:25 2010 +0800
+++ b/cgi-bin/LJ/Directory/Constraint/Interest.pm	Tue Dec 28 21:24:15 2010 +0800
@@ -29,8 +29,15 @@ sub new_from_formargs {
 sub new_from_formargs {
     my ($pkg, $args) = @_;
     return undef unless ($args->{int_like} xor $args->{intid});
-    return $pkg->new(intid    => $args->{intid},
-                     interest => $args->{int_like});
+
+    # handle possibility of multiple specified interests
+    my @ints = LJ::interest_string_to_list( $args->{int_like} );
+
+    if ( $args->{int_like} ) {
+        return [ map { $pkg->new( interest => $_ ) } @ints ];
+    } else {
+        return $pkg->new( intid => $args->{intid} );
+    }
 }
 
 sub cache_for { 5 * 60 }
--------------------------------------------------------------------------------

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