diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-16 21:23:54 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-16 21:23:54 +0000 |
commit | a7033c8bacdaf476d79a40ac0311bac0c177ae62 (patch) | |
tree | 633ac1d745987c08fb90d1329b4b7fc265b8ec39 | |
parent | 446889b3f0cbb8d66d5b72605b14518f01afd17c (diff) | |
download | redmine-a7033c8bacdaf476d79a40ac0311bac0c177ae62.tar.gz redmine-a7033c8bacdaf476d79a40ac0311bac0c177ae62.zip |
Code improvement in ProjectsController#activity (Nicolas Chuche)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@650 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/projects_controller.rb | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 920dbd5e4..73d3ee05f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -472,15 +472,13 @@ class ProjectsController < ApplicationController @date_from = Date.civil(@year, @month, 1) @date_to = @date_from >> 1 - @events_by_day = {} + @events_by_day = Hash.new { |h,k| h[k] = [] } unless params[:show_issues] == "0" @project.issues.find(:all, :include => [:author], :conditions => ["#{Issue.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to] ).each { |i| - @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i } @project.issue_changes.find(:all, :include => :details, :conditions => ["(#{Journal.table_name}.created_on BETWEEN ? AND ?) AND (#{JournalDetail.table_name}.prop_key = 'status_id')", @date_from, @date_to] ).each { |i| - @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i } @show_issues = 1 @@ -488,7 +486,6 @@ class ProjectsController < ApplicationController unless params[:show_news] == "0" @project.news.find(:all, :conditions => ["#{News.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to], :include => :author ).each { |i| - @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i } @show_news = 1 @@ -497,9 +494,8 @@ class ProjectsController < ApplicationController unless params[:show_files] == "0" Attachment.find(:all, :select => "#{Attachment.table_name}.*", :joins => "LEFT JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Attachment.table_name}.container_id", - :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to], + :conditions => ["#{Attachment.table_name}.container_type='Version' and #{Version.table_name}.project_id=? and #{Attachment.table_name}.created_on BETWEEN ? AND ? ", @project.id, @date_from, @date_to], :include => :author ).each { |i| - @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i } @show_files = 1 @@ -507,14 +503,12 @@ class ProjectsController < ApplicationController unless params[:show_documents] == "0" @project.documents.find(:all, :conditions => ["#{Document.table_name}.created_on BETWEEN ? AND ?", @date_from, @date_to] ).each { |i| - @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i } Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN #{Document.table_name} ON #{Document.table_name}.id = #{Attachment.table_name}.container_id", - :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on BETWEEN ? AND ?", @project.id, @date_from, @date_to], + :conditions => ["#{Attachment.table_name}.container_type='Document' and #{Document.table_name}.project_id=? and #{Attachment.table_name}.created_on BETWEEN ? AND ? ", @project.id, @date_from, @date_to], :include => :author ).each { |i| - @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i } @show_documents = 1 @@ -533,8 +527,6 @@ class ProjectsController < ApplicationController def i.created_on self.updated_on end - - @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i } @show_wiki_edits = 1 @@ -545,7 +537,6 @@ class ProjectsController < ApplicationController def i.created_on self.committed_on end - @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i } @show_changesets = 1 |