diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-11-25 16:32:07 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-11-25 16:32:07 +0000 |
commit | d638509307854382ff981f188fb6d2cd584337ec (patch) | |
tree | 0e610dab86e1c0cab1bfd9ecb4b71775dcd2196b /app/controllers/general_controller.rb | |
parent | 9ebe45cc5363dd7f9398b974e5a48530a27d8d28 (diff) | |
parent | d29ab6b1ef7b005b3dbd2e0f1c295e2022794267 (diff) |
Merge branch 'feature/restore-caching' into rails-3-develop
Diffstat (limited to 'app/controllers/general_controller.rb')
-rw-r--r-- | app/controllers/general_controller.rb | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index beefef4e6..aac078829 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -12,52 +12,7 @@ class GeneralController < ApplicationController # New, improved front page! def frontpage medium_cache - # get some example searches and public bodies to display - # either from config, or based on a (slow!) query if not set - body_short_names = AlaveteliConfiguration::frontpage_publicbody_examples.split(/\s*;\s*/).map{|s| "'%s'" % s.gsub(/'/, "''") }.join(", ") @locale = self.locale_from_params() - locale_condition = 'public_body_translations.locale = ?' - conditions = [locale_condition, @locale] - I18n.with_locale(@locale) do - if body_short_names.empty? - # This is too slow - @popular_bodies = PublicBody.visible.find(:all, - :order => "info_requests_count desc", - :limit => 32, - :conditions => conditions, - :joins => :translations - ) - else - conditions[0] += " and public_bodies.url_name in (" + body_short_names + ")" - @popular_bodies = PublicBody.find(:all, - :conditions => conditions, - :joins => :translations) - end - end - # Get some successful requests - begin - query = 'variety:response (status:successful OR status:partially_successful)' - sortby = "newest" - max_count = 5 - xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count) - @request_events = xapian_object.results.map { |r| r[:model] } - - # If there are not yet enough successful requests, fill out the list with - # other requests - if @request_events.count < max_count - @request_events_all_successful = false - query = 'variety:sent' - xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count-@request_events.count) - more_events = xapian_object.results.map { |r| r[:model] } - @request_events += more_events - # Overall we still want the list sorted with the newest first - @request_events.sort!{|e1,e2| e2.created_at <=> e1.created_at} - else - @request_events_all_successful = true - end - rescue - @request_events = [] - end end # Display blog entries |