aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-05-13 10:17:32 +0100
committerGareth Rees <gareth@mysociety.org>2015-05-13 10:17:32 +0100
commit117fee28f8ed52ad8a45499505a62ff6e93ebe45 (patch)
tree037da2bede4669d03fccb5f9c1b000062cb2ef55 /app/models/info_request.rb
parent8f9984b66c7ce5d38b07bb6dfef28e914894a92c (diff)
parent486a1ef2c11cfd0a9063cc1b4638d8ff651d549e (diff)
Merge branch '2241-admin-summary-performance' into rails-3-develop
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 01d5f5c52..3a81860ad 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -777,7 +777,14 @@ public
end
def public_response_events
- self.info_request_events.select{|e| e.response? && e.incoming_message.all_can_view? }
+ condition = <<-SQL
+ info_request_events.event_type = ?
+ AND incoming_messages.prominence = ?
+ SQL
+
+ info_request_events.
+ joins(:incoming_message).
+ where(condition, 'response', 'normal')
end
# The last public response is the default one people might want to reply to
@@ -1384,6 +1391,15 @@ public
end
end
+ # The DateTime of the last InfoRequestEvent belonging to the InfoRequest
+ # Only available if the last_event_time attribute has been set. This is
+ # currentlt only set through .find_in_state
+ #
+ # Returns a DateTime
+ def last_event_time
+ attributes['last_event_time'].try(:to_datetime)
+ end
+
private
def set_defaults