aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/info_request.rb3
-rw-r--r--app/models/info_request_event.rb18
2 files changed, 19 insertions, 2 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index c667e1499..9b0f1047b 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -451,7 +451,7 @@ public
self.log_event("response", params)
self.save!
end
-
+ self.info_request_events.each { |event| event.xapian_mark_needs_index } # for the "waiting_classification" index
RequestMailer.deliver_new_response(self, incoming_message)
end
@@ -564,6 +564,7 @@ public
def calculate_event_states
curr_state = nil
for event in self.info_request_events.reverse
+ event.xapian_mark_needs_index # we need to reindex all events in order to update their latest_* terms
if curr_state.nil?
if !event.described_state.nil?
curr_state = event.described_state
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 1550a4bf5..fbf70332d 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -94,7 +94,7 @@ class InfoRequestEvent < ActiveRecord::Base
[ :created_at_numeric, 1, "created_at", :number ], # for sorting
[ :described_at_numeric, 2, "described_at", :number ], # XXX using :number for lack of :datetime support in Xapian values
[ :request, 3, "request_collapse", :string ],
- [ :request_title_collapse, 4, "request_title_collapse", :string ]
+ [ :request_title_collapse, 4, "request_title_collapse", :string ],
],
:terms => [ [ :calculated_state, 'S', "status" ],
[ :requested_by, 'B', "requested_by" ],
@@ -102,6 +102,9 @@ class InfoRequestEvent < ActiveRecord::Base
[ :commented_by, 'C', "commented_by" ],
[ :request, 'R', "request" ],
[ :variety, 'V', "variety" ],
+ [ :latest_variety, 'K', "latest_variety" ],
+ [ :latest_status, 'L', "latest_status" ],
+ [ :waiting_classification, 'W', "waiting_classification" ],
[ :filetype, 'T', "filetype" ],
[ :tags, 'U', "tag" ]
],
@@ -129,6 +132,19 @@ class InfoRequestEvent < ActiveRecord::Base
def request
self.info_request.url_title
end
+
+ def latest_variety
+ self.info_request.get_last_event.variety
+ end
+
+ def latest_status
+ self.info_request.get_last_event.calculated_state
+ end
+
+ def waiting_classification
+ self.info_request.awaiting_description == true ? "yes" : "no"
+ end
+
def request_title_collapse
url_title = self.info_request.url_title
# remove numeric section from the end, use this to group lots