noosfero | search: on crash, don't let exception load all data

Bráulio Bhavamitra gitlab at gitlab.com
Sun Mar 1 21:38:45 BRT 2015


Bráulio Bhavamitra pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>

Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/82742464704b48dce6337fa31610da3db7a6bce4">82742464</a> by Braulio Bhavamitra
search: on crash, don't let exception load all data

@scope will load all data from environment with there is crash on
search, consuming many resources on server

- - - - -


Changes:

=====================================
app/controllers/public/search_controller.rb
=====================================
--- a/app/controllers/public/search_controller.rb
+++ b/app/controllers/public/search_controller.rb
@@ -61,7 +61,7 @@ class SearchController < PublicController
   end
 
   def articles
-    @scope = @environment.articles.public
+    @scope = @environment.articles.public.paginate(paginate_options)
     full_text_search
   end
 
@@ -75,7 +75,7 @@ class SearchController < PublicController
   end
 
   def products
-    @scope = @environment.products
+    @scope = @environment.products.paginate(paginate_options)
     full_text_search
   end
 
@@ -238,7 +238,7 @@ class SearchController < PublicController
   def visible_profiles(klass, *extra_relations)
     relations = [:image, :domains, :environment, :preferred_domain]
     relations += extra_relations
-    @environment.send(klass.name.underscore.pluralize).visible.includes(relations)
+    @environment.send(klass.name.underscore.pluralize).visible.includes(relations).paginate(paginate_options)
   end
 
   def per_page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150302/540ef3b1/attachment.html>


More information about the Noosfero-dev mailing list