diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/info_request.rb | 7 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 7 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 3f5224907..7ba370838 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -146,6 +146,13 @@ class InfoRequest < ActiveRecord::Base info_request_event.xapian_mark_needs_index end end + # Force reindex when tag string changes + alias_method :orig_tag_string=, :tag_string= + def tag_string=(tag_string) + ret = self.orig_tag_string=(tag_string) + reindex_request_events + return ret + end # Removes anything cached about the object in the database, and saves def clear_in_database_caches! diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 4a659dc65..8ad2d5964 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -109,7 +109,8 @@ class InfoRequestEvent < ActiveRecord::Base [ :commented_by, 'C', "commented_by" ], [ :request, 'R', "request" ], [ :variety, 'V', "variety" ], - [ :filetype, 'T', "filetype" ] + [ :filetype, 'T', "filetype" ], + [ :tags, 'U', "tag" ] ], :if => :indexed_by_search?, :eager_load => [ :incoming_message, :outgoing_message, :comment, { :info_request => [ :user, :public_body, :censor_rules ] } ] @@ -188,6 +189,10 @@ class InfoRequestEvent < ActiveRecord::Base end return '' end + def tags + # this returns an array of strings, each gets indexed as separate term by acts_as_xapian + return self.info_request.tag_array_for_search + end def indexed_by_search? if ['sent', 'followup_sent', 'response', 'comment'].include?(self.event_type) if !self.info_request.indexed_by_search? |