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

[livejournal] r19901: LJSUP-9661.

Committer: gprochaev
LJSUP-9661.

U   trunk/cgi-bin/LJ/Browse.pm
U   trunk/cgi-bin/LJ/Vertical.pm
U   trunk/cgi-bin/LJ/Widget/Browse.pm
Modified: trunk/cgi-bin/LJ/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Browse.pm	2011-08-31 03:31:32 UTC (rev 19900)
+++ trunk/cgi-bin/LJ/Browse.pm	2011-08-31 03:34:22 UTC (rev 19901)
@@ -958,9 +958,9 @@
     my $comm_list = join ",", @$comms;
     my $dbh = LJ::get_db_reader();
 
-    if (my @search_words = split /\s+/, $search) {
+    if (length $search) {
         ## Search for keyword ids for search string
-        my $where_search = join " OR ", map { " keyword LIKE '%".$_."%' " } @search_words;
+        my $where_search = " keyword = '".$search."' ";
         my $keyword_ids = $dbh->selectall_arrayref (
                                 "SELECT kw_id FROM vertical_keywords WHERE $where_search",
                                 { Slice => {} }
@@ -974,7 +974,7 @@
         my @vals = map { $_->{kw_id} } @$keyword_ids;
         my $where = $vertical ? " AND km.vert_id = " . $vertical->vert_id : "";
         my $posts = $dbh->selectall_arrayref (
-                                "SELECT * FROM vertical_keymap WHERE kw_id IN ($ph) $where", 
+                                "SELECT * FROM vertical_keymap km WHERE kw_id IN ($ph) $where", 
                                 { Slice => {} }, 
                                 @vals
                           ) || [];

Modified: trunk/cgi-bin/LJ/Vertical.pm
===================================================================
--- trunk/cgi-bin/LJ/Vertical.pm	2011-08-31 03:31:32 UTC (rev 19900)
+++ trunk/cgi-bin/LJ/Vertical.pm	2011-08-31 03:34:22 UTC (rev 19901)
@@ -358,13 +358,8 @@
     my $comm_interests = $dbh->selectcol_arrayref (
         "SELECT intid
             FROM interests i
-            WHERE EXISTS (
-                SELECT 1 
-                    FROM (
-                        $search
-                    ) c 
-                WHERE i.interest LIKE cond
-            )"
+            WHERE i.interest = ?
+        ", undef, $search
     );
 
     return $comms unless $comm_interests && @$comm_interests;
@@ -397,10 +392,7 @@
 
     my $comms_search = [];
     my %finded = ();
-    if (bytes::length($search)) {
-        my @search_words = map { "SELECT '%".$_."%' AS cond" } split /\s+/, $search;
-        $search = join " UNION ALL ", @search_words;
-
+    if (length $search) {
         ## Fetch suitable communities from community directory
         $comms_search = $dbh->selectall_arrayref (
             "SELECT DISTINCT journalid
@@ -410,15 +402,9 @@
                 AND kw_id IN (
                     SELECT kw_id
                         FROM vertical_keywords kw
-                        WHERE EXISTS (
-                            SELECT 1 
-                                FROM (
-                                    $search
-                                ) c 
-                            WHERE kw.keyword LIKE cond
-                        )
+                        WHERE kw.keyword = ?
                     )",
-            { Slice => {} }, $self->vert_id
+            { Slice => {} }, $self->vert_id, $search,
         ) || [];
         %finded = map { $_->{journalid} => 1 } @$comms_search;
 

Modified: trunk/cgi-bin/LJ/Widget/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Browse.pm	2011-08-31 03:31:32 UTC (rev 19900)
+++ trunk/cgi-bin/LJ/Widget/Browse.pm	2011-08-31 03:34:22 UTC (rev 19901)
@@ -382,7 +382,12 @@
             @tmpl_posts = @{$result->{'posts'}};
             $post_count = $result->{'post_count'};
         } else {
-            my @posts = LJ::Browse->search_posts ( comms => [ map { $_->{userid} } @comms ], page_size => 300, search_str => $search_str );
+            my @posts = LJ::Browse->search_posts (
+                comms       => [ map { $_->{userid} } @comms ],
+                page_size   => 300,
+                search_str  => $search_str,
+                vertical    => $vertical,
+            );
 
             my $result = render_posts ( \@posts, post_skip => $post_skip, post_last => $post_last );
             @tmpl_posts = @{$result->{'posts'}};

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