aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb@mysociety.org>2012-01-09 09:32:02 +0000
committerSeb Bacon <seb@mysociety.org>2012-01-09 09:32:02 +0000
commitba6ea061868d007aae412635b6ea736eb0db5688 (patch)
tree0d719c81927a7077d4a1a84c274121b900161b98
parente3d409971edd73e11e09e8938e54b0e7cc9e6c92 (diff)
What an extraordinary bug
The admin timeline code was fetching *all* outgoing messages, rather than just the one particular one we wanted; and similarly for comments. Unsurprising this was rather slow.
-rw-r--r--app/views/admin_general/timeline.rhtml10
1 files changed, 4 insertions, 6 deletions
diff --git a/app/views/admin_general/timeline.rhtml b/app/views/admin_general/timeline.rhtml
index dc72e46cd..39a4b3e36 100644
--- a/app/views/admin_general/timeline.rhtml
+++ b/app/views/admin_general/timeline.rhtml
@@ -36,10 +36,9 @@
end
%>
<% elsif event.event_type == 'edit_outgoing' %>
- <% outgoing_messages = OutgoingMessage.find(:all, event.params[:outgoing_message_id].to_i) %>
+ <% outgoing_message = OutgoingMessage.find(event.params[:outgoing_message_id].to_i) %>
had outgoing message edited by administrator <strong><%=h event.params[:editor] %></strong>.
- <% if outgoing_messages.size > 0 %>
- <% outgoing_message = outgoing_messages[0] %>
+ <% if outgoing_message %>
<% for p in ['body']
if event.params[p.to_sym] != event.params[('old_'+p).to_sym]
%> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <%
@@ -50,10 +49,9 @@
Missing outgoing message, internal error.
<% end %>
<% elsif event.event_type == 'edit_comment' %>
- <% comments = Comment.find(:all, event.params[:comment_id].to_i) %>
+ <% comment = Comment.find(event.params[:comment_id].to_i) %>
had annotation edited by administrator <strong><%=h event.params[:editor] %></strong>.
- <% if comments.size > 0 %>
- <% comment = comments[0] %>
+ <% if comment %>
<% for p in ['body']
if event.params[p.to_sym] != event.params[('old_'+p).to_sym]
%> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <%