From 967a6086db39e0781e5290e86b88b4cc489d2ab7 Mon Sep 17 00:00:00 2001 From: francis Date: Wed, 22 Apr 2009 01:10:32 +0000 Subject: When URL of request changes, reindex its events. --- app/models/info_request.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/models/info_request.rb') diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 025a9247e..a37baf8d8 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -23,7 +23,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.186 2009-04-13 09:18:48 tony Exp $ +# $Id: info_request.rb,v 1.187 2009-04-22 01:10:33 francis Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -105,6 +105,18 @@ class InfoRequest < ActiveRecord::Base ) end + # if the URL name has changed, then all request: queries + # will break unless we update index for every event + after_save :reindex_request_events + def reindex_request_events + if self.changes.include?('url_title') + for info_request_event in self.info_request_events + info_request_event.xapian_mark_needs_index + end + end + end + + # For debugging def InfoRequest.profile_search(query) t = Time.now.usec -- cgit v1.2.3