myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2779] trunk: fixed error page with invalid searc


From: noreply
Subject: [myexperiment-hackers] [2779] trunk: fixed error page with invalid search queries
Date: Tue, 1 Nov 2011 10:57:57 -0400 (EDT)

Revision
2779
Author
dgc
Date
2011-11-01 10:57:56 -0400 (Tue, 01 Nov 2011)

Log Message

fixed error page with invalid search queries

Modified Paths

Diff

Modified: trunk/app/controllers/application.rb (2778 => 2779)


--- trunk/app/controllers/application.rb	2011-11-01 09:21:32 UTC (rev 2778)
+++ trunk/app/controllers/application.rb	2011-11-01 14:57:56 UTC (rev 2779)
@@ -740,10 +740,14 @@
 
     def create_search_results_table(search_query, models)
 
-      solr_results = models.first.multi_solr_search(search_query,
-          :models         => models,
-          :results_format => :ids,
-          :limit          => Conf.max_search_size)
+      begin
+        solr_results = models.first.multi_solr_search(search_query,
+            :models         => models,
+            :results_format => :ids,
+            :limit          => Conf.max_search_size)
+      rescue
+        return false
+      end
 
       conn =  ActiveRecord::Base.connection
 
@@ -763,6 +767,8 @@
  
         conn.execute("INSERT INTO search_results VALUES #{insert_part}")
       end
+
+      true
     end
 
     def drop_search_results_table
@@ -1010,10 +1016,16 @@
 
     group_by = "contributions.contributable_type, contributions.contributable_id"
 
+    query_problem = false
+
     if params["query"]
       drop_search_results_table
-      create_search_results_table(params["query"], [Workflow, Blob, Pack, User, Network, Service])
-      joins.push(:search) unless opts[:arbitrary_models]
+      if create_search_results_table(params["query"], [Workflow, Blob, Pack, User, Network, Service])
+        joins.push(:search) unless opts[:arbitrary_models]
+      else
+        params["query"] = nil
+        query_problem = true
+      end
     end
 
     if opts[:arbitrary_models] && params[:query]
@@ -1157,7 +1169,8 @@
       :reset_filters_url       => reset_filters_url,
       :cancel_filter_query_url => cancel_filter_query_url,
       :filter_query_url        => build_url(params, opts, opts[:filters], [:filter]),
-      :summary                 => summary
+      :summary                 => summary,
+      :query_problem           => query_problem
     }
   end
 end

Modified: trunk/app/views/content/_index.rhtml (2778 => 2779)


--- trunk/app/views/content/_index.rhtml	2011-11-01 09:21:32 UTC (rev 2778)
+++ trunk/app/views/content/_index.rhtml	2011-11-01 14:57:56 UTC (rev 2779)
@@ -77,6 +77,11 @@
             <% end %>
             <input class="submit" type="submit" value="Search"></input>
           </div>
+          <% if @pivot[:query_problem] %>
+            <div class="search_query_problem">
+              There was a problem with your search query.
+            </div>
+          <% end %>
           <% if params[:query] && controller.class != SearchController %>
             <div class="remove_search_query">
               <%= link_to("Remove search query", url_for(request.query_parameters.merge({ "query", nil }))) -%>

Modified: trunk/public/stylesheets/styles.css (2778 => 2779)


--- trunk/public/stylesheets/styles.css	2011-11-01 09:21:32 UTC (rev 2778)
+++ trunk/public/stylesheets/styles.css	2011-11-01 14:57:56 UTC (rev 2779)
@@ -2246,6 +2246,11 @@
   top: -1px;
 }
 
+.pivot .search_query_problem {
+  color: red;
+	font-style: italic;
+}
+
 .truncate {
   white-space: nowrap;
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]