wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r18656: LJSUP-8270. search functional

Committer: gprochaev
LJSUP-8270. search functional

U   trunk/cgi-bin/LJ/Vertical.pm
Modified: trunk/cgi-bin/LJ/Vertical.pm
===================================================================
--- trunk/cgi-bin/LJ/Vertical.pm	2011-03-21 10:43:40 UTC (rev 18655)
+++ trunk/cgi-bin/LJ/Vertical.pm	2011-03-21 11:00:31 UTC (rev 18656)
@@ -348,7 +348,7 @@
 
 sub get_communities_by_interests {
     my $class = shift;
-    my $interests = shift;
+    my $search = shift;
 
     my $dbh = LJ::get_db_writer()
         or die "unable to contact global db master to create vertical";
@@ -356,10 +356,15 @@
     my $comms = [];
 
     my $comm_interests = $dbh->selectcol_arrayref (
-        "SELECT intid 
-            FROM interests
-            WHERE interest
-            IN ('" . $interests . "')",
+        "SELECT intid
+            FROM interests i
+            WHERE EXISTS (
+                SELECT 1 
+                    FROM (
+                        $search
+                    ) c 
+                WHERE i.interest LIKE cond
+            )"
     );
 
     return $comms unless $comm_interests && @$comm_interests;
@@ -390,7 +395,6 @@
 
     my $comms_search = [];
     my %finded = ();
-    my $join_search_words = join "','", split /\s+/, $search;
     if (bytes::length($search)) {
         my @search_words = map { "SELECT '%".$_."%' AS cond" } split /\s+/, $search;
         $search = join " UNION ALL ", @search_words;
@@ -417,7 +421,7 @@
         %finded = map { $_->{journalid} => 1 } @$comms_search;
 
         ## Search communities by interests
-        my $comms = LJ::Vertical->get_communities_by_interests ($join_search_words);
+        my $comms = LJ::Vertical->get_communities_by_interests ($search);
         my $comms_search = [];
 
         if ($comms && @$comms) {

Tags: livejournal, pm, wisest-owl
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