<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,6 +11,8 @@ doc/app
 config/database.yml
 config/deploy.rb
 public/mugshots
+public/stylesheets/cache
+public/javascripts/cache
 .project
 .loadpath
 nbproject</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -3,48 +3,101 @@ class DashboardController &lt; ApplicationController
   before_filter :login_required
 
   def index
-    if params[:game_id] &amp;&amp; params[:game_id].to_i != current_game.id
-      @game = current_account.games.find(params[:game_id])
-    end
-    @game ||= current_game
+    return if game.nil?
 
-    return if @game.nil?
-
-    @logs = @game.logs.find(:all, :order =&gt; 'published_at DESC', :limit =&gt; 5)
     if params[:last_update]
-      if @logs.size &gt; 0 &amp;&amp; @logs.first.published_at.to_s(:db) != params[:last_update]
-        load_data
+      if logs.size &gt; 0 &amp;&amp; last_update != params[:last_update]
         render :action =&gt; 'index', :layout =&gt; false
       else
         head 200
       end
-    else
-      load_data
     end
   end
+  
+  helper_method :game
+  helper_method :logs
+  helper_method :last_update
+  helper_method :last_update_cache_key
+  helper_method :recent_matches
+  helper_method :rankings
+  helper_method :newbies
+  helper_method :matches_per_day
+  helper_method :leader
+  helper_method :match_count
+  helper_method :points
+  helper_method :all_time_high
+  helper_method :all_time_low
+  helper_method :positions
+  helper_method :news
 
   protected
-  def load_data
-    @recent_matches = @game.matches.find_recent(nil,
-                                                :limit =&gt; 10,
-                                                :include =&gt; { :teams =&gt; :memberships })
-
-    @rankings = @game.ranked_game_participators
-    @newbies = @game.newbie_game_participators
-    @matches_per_day = @game.matches.count(:group =&gt; :played_on,
+  def game
+    return @game unless @game.nil?
+    if params[:game_id] &amp;&amp; params[:game_id].to_i != current_game.id
+      @game = current_account.games.find(params[:game_id])
+    end
+    @game ||= current_game
+  end
+
+  def logs
+    return nil if game.nil?
+    @logs ||= game.logs.find(:all, :order =&gt; 'published_at DESC', :limit =&gt; 5)
+  end 
+  
+  def last_update
+    return nil if logs.nil? || logs.first.nil?
+    logs.first.published_at.to_s(:db)
+  end
+
+  def last_update_cache_key
+    last_update.gsub(' ', '-')
+  end
+   
+  def recent_matches
+    @recent_matches ||= @game.matches.find_recent(nil,
+                                                  :limit =&gt; 10,
+                                                  :include =&gt; { :teams =&gt; :memberships })
+  end
+
+  def rankings
+    @rankings ||= @game.ranked_game_participators
+  end
+
+  def newbies
+    @newbies ||= @game.newbie_game_participators
+  end
+
+  def matches_per_day
+    @matches_per_day ||= @game.matches.count(:group =&gt; :played_on,
                                            :limit =&gt; 10,
                                            :order =&gt; 'matches.played_on DESC')
+  end
 
-    # Sidebar
-    @leader = @rankings.size &gt; 0 ? @rankings[0] : @newbies[0]
-    @match_count = @game.matches.count
+  def leader
+    @leader ||= rankings.size &gt; 0 ? rankings[0] : newbies[0]
+  end
 
+  def match_count
+    @match_count ||= @game.matches.size
+  end
+
+  def points
+    return @points unless @points.nil?
     total_points_for = @game.game_participations.sum(:points_for)
-    @points = total_points_for.nil? ? 0 : total_points_for / @game.team_size
+    @points ||= total_points_for.nil? ? 0 : total_points_for / @game.team_size
+  end
 
-    @all_time_high = Membership.all_time_high(current_game)
-    @all_time_low = Membership.all_time_low(current_game)
+  def all_time_high
+    @all_time_high ||= Membership.all_time_high(current_game)
+  end
 
+  def all_time_low
+    @all_time_low ||= Membership.all_time_low(current_game)
+  end
+
+  def positions
+    return @positions unless @positions.nil?
+    
     # Get positions 7 days ago
     @positions = {}
     last_month = @game.matches.find(:first,
@@ -58,6 +111,10 @@ class DashboardController &lt; ApplicationController
       end
     end
 
-    @news = NewsItem.find(:all, :order =&gt; 'posted_at DESC', :limit =&gt; 3)
+    @positions
+  end
+
+  def news
+    @news ||= NewsItem.find(:all, :order =&gt; 'posted_at DESC', :limit =&gt; 3)
   end
 end</diff>
      <filename>app/controllers/dashboard_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,7 @@ module LogsHelper
   
   def log_feed_url(game, options = {}, user = nil)
     user ||= current_user
-    formatted_game_logs_url(game, :atom, {:feed_token =&gt; user.feed_token}.merge(options))
+    game_logs_url(game, {:feed_token =&gt; user.feed_token}.merge(options), :format =&gt; :atom)
   end
   
   def format_message(game_id, message)</diff>
      <filename>app/helpers/logs_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,8 +26,8 @@
           - if start_at == 1
             %td
               - if game_participation.user.created_at &lt;= 7.days.ago
-                = position_icon(@positions[game_participation.user_id])
-                = '(' + @positions[game_participation.user_id][:then].to_s + ')' unless @positions[game_participation.user_id].blank?
+                = position_icon(positions[game_participation.user_id])
+                = '(' + positions[game_participation.user_id][:then].to_s + ')' unless positions[game_participation.user_id].blank?
               - else
                 &amp;nbsp;
           %td</diff>
      <filename>app/views/dashboard/_leaderboard.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -3,8 +3,8 @@
   
   %h3= 'Events'[]
   .list
-    - @logs.each do |log|
-      %span.log{ :class =&gt; log == @logs.last ? 'last' : nil }
+    - logs.each do |log|
+      %span.log{ :class =&gt; log == logs.last ? 'last' : nil }
         = log_link log
         
 - content_for :head do</diff>
      <filename>app/views/dashboard/_logs.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,68 +1,72 @@
 - title 'Dashboard'[]
 
-- if @logs.size &gt; 0
-  = render :partial =&gt; 'logs', :locals =&gt; { :logs =&gt; @logs }
+- cache([game, last_update_cache_key, 'dashboard']) do
+  - if logs.size &gt; 0
+    = render :partial =&gt; 'logs', :locals =&gt; { :logs =&gt; logs }
 
-- form_tag game_comparisons_path(current_game), :method =&gt; :get do
-  #leaderboards
-    - if @rankings.size &gt; 0
-      = render :partial =&gt; 'leaderboard', :locals =&gt; { :game_participations =&gt; @rankings, :start_at =&gt; 1, :title =&gt; 'Rankings'[], :details =&gt; '', :board_id =&gt; 'rankings' }
+  - form_tag game_comparisons_path(current_game), :method =&gt; :get do
+    #leaderboards
+      - if rankings.size &gt; 0
+        = render :partial =&gt; 'leaderboard', :locals =&gt; { :game_participations =&gt; rankings, :start_at =&gt; 1, :title =&gt; 'Rankings'[], :details =&gt; '', :board_id =&gt; 'rankings' }
 
-    - if @newbies.size &gt; 0
-      = render :partial =&gt; 'leaderboard', :locals =&gt; { :game_participations =&gt; @newbies, :start_at =&gt; @rankings.size + 1, :title =&gt; 'Newbies'[], :details =&gt; &quot;- less than {limit} matches&quot;[:less_than_matches, @game.newbie_limit], :board_id =&gt; 'newbies' }
+      - if newbies.size &gt; 0
+        = render :partial =&gt; 'leaderboard', :locals =&gt; { :game_participations =&gt; newbies, :start_at =&gt; rankings.size + 1, :title =&gt; 'Newbies'[], :details =&gt; &quot;- less than {limit} matches&quot;[:less_than_matches, game.newbie_limit], :board_id =&gt; 'newbies' }
 
-- if @recent_matches.size &gt; 0
-  = render :partial =&gt; 'recent_matches', :locals =&gt; { :recent_matches =&gt; @recent_matches }
-- else
-  #no_data= 'There are no matches in the database yet.'[]
-      
+  - if recent_matches.size &gt; 0
+    = render :partial =&gt; 'recent_matches', :locals =&gt; { :recent_matches =&gt; recent_matches }
+  - else
+    #no_data= 'There are no matches in the database yet.'[]
+    
+  
 - content_for :sidebar do
-  - unless @leader.nil?
-    #leader
-      %h3= 'Leader'[]
-      .mugshot= link_to image_tag(@leader.user.mugshot.public_filename(:thumb), :alt =&gt; @leader.user.name), game_user_path(@game, @leader.user) if @leader.user.mugshot
-      = user_link_full @game, @leader.user
+  - cache([game, last_update_cache_key, 'sidebar']) do
+    - unless leader.nil?
+      #leader
+        %h3= 'Leader'[]
+        .mugshot= link_to image_tag(leader.user.mugshot.public_filename(:thumb), :alt =&gt; leader.user.name), game_user_path(game, leader.user) if leader.user.mugshot
+        = user_link_full game, leader.user
 
-  #counts
-    %h3= 'Totals'[]
+    #counts
+      %h3= 'Totals'[]
   
-    %table
-      %tr
-        %td
-          %label= 'Matches'[] + ':'
-          = @match_count
-        %td
-          %label= 'Points'[] + ':'
-          = @points
-      - unless @all_time_high.nil? &amp;&amp; @all_time_low.nil?
+      %table
         %tr
           %td
-            - unless @all_time_high.nil?
-              %label= 'All time high'[] + ':'
-              = link_to @all_time_high.current_ranking, game_match_path(@game, @all_time_high.team.match), :class =&gt; 'match'
-              = 'by'[]
-              %br
-              = user_link @game, find_user(@all_time_high.user_id)
+            %label= 'Matches'[] + ':'
+            = match_count
           %td
-            - unless @all_time_low.nil?
-              %label= 'All time low'[] + ':'
-              = link_to @all_time_low.current_ranking, game_match_path(@game, @all_time_low.team.match), :class =&gt; 'match'
-              = 'by'[]
-              %br
-              = user_link @game, find_user(@all_time_low.user_id)
+            %label= 'Points'[] + ':'
+            = points
+        - unless all_time_high.nil? &amp;&amp; all_time_low.nil?
+          %tr
+            %td
+              - unless all_time_high.nil?
+                %label= 'All time high'[] + ':'
+                = link_to all_time_high.current_ranking, game_match_path(game, all_time_high.team.match), :class =&gt; 'match'
+                = 'by'[]
+                %br
+                = user_link game, find_user(all_time_high.user_id)
+            %td
+              - unless all_time_low.nil?
+                %label= 'All time low'[] + ':'
+                = link_to all_time_low.current_ranking, game_match_path(game, all_time_low.team.match), :class =&gt; 'match'
+                = 'by'[]
+                %br
+                = user_link game, find_user(all_time_low.user_id)
 
-    - if @matches_per_day.size &gt; 0
-      = render :partial =&gt; 'matches/per_day', :locals =&gt; { :matches_per_day =&gt; @matches_per_day }
+      - if matches_per_day.size &gt; 0
+        = render :partial =&gt; 'matches/per_day', :locals =&gt; { :matches_per_day =&gt; matches_per_day }
       
-    #news
-      %h3= 'News'[]
-      %ul
-        - @news.each do |news|
-          %li
-            = link_to news.name, news.url
-            %span= news.posted_at.to_date.to_s :long
+      - if news.size &gt; 0
+        #news
+          %h3= 'News'[]
+          %ul
+            - news.each do |news|
+              %li
+                = link_to news.name, news.url
+                %span= news.posted_at.to_date.to_s :long
       
 #dashboard_data
-  - if @logs &amp;&amp; @logs.first
-    .last_update= @logs.first.published_at.to_s(:db)
-  .game_id= @game.id
\ No newline at end of file
+  - if logs &amp;&amp; logs.first
+    .last_update= last_update
+  .game_id= game.id
\ No newline at end of file</diff>
      <filename>app/views/dashboard/index.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -72,4 +72,5 @@ Rails::Initializer.run do |config|
 
   # Application configuration should go into files in config/initializers
   # -- all .rb files in that directory is automatically loaded
+  config.cache_store = :mem_cache_store, '127.0.0.1:12001'
 end</diff>
      <filename>config/environment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ config.whiny_nils = true
 
 # Show full error reports and disable caching
 config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching             = false
+config.action_controller.perform_caching             = true
 config.action_view.debug_rjs                         = true
 
 # Don't care if the mailer can't send</diff>
      <filename>config/environments/development.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>859848a077f18d165d8a83ed916f10cf6d18f7ea</id>
    </parent>
  </parents>
  <author>
    <name>Lars G. Sehested</name>
    <email>lars@larssehested.com</email>
  </author>
  <url>http://github.com/larssg/score-keeper/commit/e9afbb1d54a7137c967a32b5b010078e3265049b</url>
  <id>e9afbb1d54a7137c967a32b5b010078e3265049b</id>
  <committed-date>2009-06-27T14:48:37-07:00</committed-date>
  <authored-date>2009-06-27T14:48:37-07:00</authored-date>
  <message>Use memcached to cache dashboard.</message>
  <tree>5402a9abc998fced58a3c9d74a0be36f546ee4ca</tree>
  <committer>
    <name>Lars G. Sehested</name>
    <email>lars@larssehested.com</email>
  </committer>
</commit>
