diff options
author | francis <francis> | 2008-03-13 12:15:21 +0000 |
---|---|---|
committer | francis <francis> | 2008-03-13 12:15:21 +0000 |
commit | 827f59c0d7356ba15bd4d9e1bb36b8eddce8a2d3 (patch) | |
tree | fc299eb7bf4060314f088fdec061c75ed413ad2b /app/models/info_request.rb | |
parent | d1481d19f0313d8dc5cf99ee0a02b648d313b813 (diff) |
hide backpaged things from search
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 3f8a56b1a..3e469fbaa 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -22,7 +22,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.62 2008-03-13 11:29:47 francis Exp $ +# $Id: info_request.rb,v 1.63 2008-03-13 12:15:21 francis Exp $ require 'digest/sha1' @@ -84,23 +84,38 @@ class InfoRequest < ActiveRecord::Base #STDERR.puts "updating id " + id.to_s ActiveRecord::Base.transaction do info_request = InfoRequest.find(id, :lock =>true) - if not info_request.solr_save - raise "failed to solr_save" + do_index = (info_request.prominence != 'backpage') + + if do_index + if not info_request.solr_save + raise "failed to solr_save" + end + else + if not info_request.solr_destroy + raise "failed to solr_destroy" + end end + for outgoing_message in info_request.outgoing_messages # Initial request text is indexed for InfoRequest models - # see :initial_request_text in acts_as_solr entry above - if outgoing_message.message_type != 'initial_request' + if do_index and outgoing_message.message_type != 'initial_request' outgoing_message.solr_save else outgoing_message.solr_destroy end end for incoming_message in info_request.incoming_messages - incoming_message.solr_save + if do_index + incoming_message.solr_save + else + incoming_message.solr_destroy + end end info_request.solr_up_to_date = true + $do_solr_index = false # disable indexing again while we save it, or else destroyed things get put back info_request.save! + $do_solr_index = true end end InfoRequest.solr_optimize |