Diff
Modified: branches/event_logging/app/views/home/_news.rhtml (1928 => 1929)
--- branches/event_logging/app/views/home/_news.rhtml 2008-11-07 14:51:44 UTC (rev 1928)
+++ branches/event_logging/app/views/home/_news.rhtml 2008-11-07 15:57:20 UTC (rev 1929)
@@ -7,7 +7,9 @@
</div>
<div class="content">
<% if logged_in? %>
- <%= render :partial => "layouts/news", :locals => { :collection => news(current_user, false, Time.now, Time.now-DEFAULT_HOME_PAGE_NEWS_TIMEFRAME, DEFAULT_HOME_PAGE_NEWS_COUNT, current_user) } %>
+ <% cache_timeout({ :controller => 'news', :action ="" 'home', :id => current_user.id } , NEWS_CACHE_TIMEOUT.seconds.from_now ) do -%>
+ <%= render :partial => "layouts/news", :locals => { :collection => news(current_user, false, Time.now, Time.now-DEFAULT_HOME_PAGE_NEWS_TIMEFRAME, DEFAULT_HOME_PAGE_NEWS_COUNT, current_user) } %>
+ <% end %>
<% else %>
<p>
<b><%= link_to "Log in", new_session_url %> to view your News</b>
Modified: branches/event_logging/app/views/networks/show.rhtml (1928 => 1929)
--- branches/event_logging/app/views/networks/show.rhtml 2008-11-07 14:51:44 UTC (rev 1928)
+++ branches/event_logging/app/views/networks/show.rhtml 2008-11-07 15:57:20 UTC (rev 1929)
@@ -150,8 +150,10 @@
<div class="tabTitle">News</div>
<div class="tabContent">
<% benchmark "Group page news feed" do %>
- <%= render :partial => "layouts/news", :locals => { :collection => news(@network, true, Time.now, Time.now-DEFAULT_GROUP_NEWS_TIMEFRAME, DEFAULT_GROUP_NEWS_COUNT, current_user) } %>
- <% end %>
+ <% cache_timeout({ :controller => 'news', :action ="" 'network_profile', :id => @network.id, :viewer => current_user.id } , NEWS_CACHE_TIMEOUT.seconds.from_now ) do -%>
+ <%= render :partial => "layouts/news", :locals => { :collection => news(@network, true, Time.now, Time.now-DEFAULT_GROUP_NEWS_TIMEFRAME, DEFAULT_GROUP_NEWS_COUNT, current_user) } %>
+ <% end -%>
+ <% end %>
</div>
</div>
Modified: branches/event_logging/app/views/users/show.rhtml (1928 => 1929)
--- branches/event_logging/app/views/users/show.rhtml 2008-11-07 14:51:44 UTC (rev 1928)
+++ branches/event_logging/app/views/users/show.rhtml 2008-11-07 15:57:20 UTC (rev 1929)
@@ -354,7 +354,9 @@
<% case @tab; when "News" %>
<% benchmark "User profile page news feed" do %>
- <%= render :partial => "layouts/news", :locals => { :collection => news(@user, true, Time.now, Time.now-DEFAULT_USER_NEWS_TIMEFRAME, DEFAULT_USER_NEWS_COUNT, current_user) } %>
+ <% cache_timeout({ :controller => 'news', :action ="" 'user_profile', :id => @user.id, :viewer => current_user.id } , NEWS_CACHE_TIMEOUT.seconds.from_now ) do -%>
+ <%= render :partial => "layouts/news", :locals => { :collection => news(@user, true, Time.now, Time.now-DEFAULT_USER_NEWS_TIMEFRAME, DEFAULT_USER_NEWS_COUNT, current_user) } %>
+ <% end %>
<% end %>
<% when "Friends" %>
Modified: branches/event_logging/config/environment_private.rb.pre (1928 => 1929)
--- branches/event_logging/config/environment_private.rb.pre 2008-11-07 14:51:44 UTC (rev 1928)
+++ branches/event_logging/config/environment_private.rb.pre 2008-11-07 15:57:20 UTC (rev 1929)
@@ -79,6 +79,10 @@
# Switch event logging on or off
USE_EVENT_LOG = true
+# News feeds have timed caches. This is duration of caching a fragment
+# of news feeds (in SECONDS)
+NEWS_CACHE_TIMEOUT = 300
+
# Default timeframes for various types of news
# [this means that only events after (Time.now - DEFAULT_<>_TIMEFRAME) will be fetched from event log]
DEFAULT_NEWS_TIMEFRAME = 1.week