aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb18
-rw-r--r--app/models/incoming_message.rb1
-rw-r--r--app/views/request/_sidebar.rhtml10
3 files changed, 17 insertions, 12 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 3b2719b5c..e9475e1b2 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -50,16 +50,18 @@ class RequestController < ApplicationController
@new_responses_count = @info_request.events_needing_description.select {|i| i.event_type == 'response'}.size
# Sidebar stuff
- limit = 3
# ... requests that have similar imporant terms
- begin
- @xapian_similar = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
- :limit => limit, :collapse_by_prefix => 'request_collapse')
- @xapian_similar_more = (@xapian_similar.matches_estimated > limit)
- rescue
- @xapian_similar = nil
+ behavior_cache :tag => ['similar', @info_request.id] do
+ begin
+ limit = 3
+ @xapian_similar = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
+ :limit => limit, :collapse_by_prefix => 'request_collapse')
+ @xapian_similar_more = (@xapian_similar.matches_estimated > limit)
+ rescue
+ @xapian_similar = nil
+ end
end
-
+
# Track corresponding to this page
@track_thing = TrackThing.create_track_for_request(@info_request)
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss] } ]
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 5800740db..136ae576d 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -1050,6 +1050,7 @@ class IncomingMessage < ActiveRecord::Base
# Returns all attachments for use in display code
# XXX is this called multiple times and should be cached?
def get_attachments_for_display
+ STDERR.puts(">>>>> get_attachments_for_display")
main_part = get_main_body_text_part
leaves = get_attachment_leaves
diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.rhtml
index 1509bf494..4a503d574 100644
--- a/app/views/request/_sidebar.rhtml
+++ b/app/views/request/_sidebar.rhtml
@@ -20,7 +20,8 @@
<%= link_to 'Start your own blog', "http://wordpress.com/"%>
</div>
- <% if !@xapian_similar.nil? && @xapian_similar.results.size > 0 %>
+ <% view_cache :ttl => 1.day, :tag => ['similar', @info_request.id] do %>
+ <% if !@xapian_similar.nil? && @xapian_similar.results.size > 0 %>
<h2>Similar requests</h2>
<% for result in @xapian_similar.results %>
<%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
@@ -30,8 +31,9 @@
<% end %>
<!-- Important terms: <%= @xapian_similar.important_terms.join(" ") %> -->
<% end %>
+ <% end %>
- <p><%= link_to "Event history details", request_details_url(@info_request) %></p>
- <p><a href="/help/about#commercial">Are you the owner of
- any commercial copyright on this page?</a></p>
+ <p><%= link_to "Event history details", request_details_url(@info_request) %></p>
+ <p><a href="/help/about#commercial">Are you the owner of
+ any commercial copyright on this page?</a></p>
</div>