From ef8dd0f64b709c6695c67877f7bc1f750f5a9396 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 28 Jul 2013 10:13:48 +0000 Subject: [PATCH] Preload some associations. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12044 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/timelog_controller.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 58f607031..96db24fdd 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -46,7 +46,9 @@ class TimelogController < ApplicationController sort_init(@query.sort_criteria.empty? ? [['spent_on', 'desc']] : @query.sort_criteria) sort_update(@query.sortable_columns) - scope = time_entry_scope(:order => sort_clause) + scope = time_entry_scope(:order => sort_clause). + includes(:project, :activity, :user, :issue). + preload(:issue => [:project, :tracker, :status, :assigned_to, :priority]) respond_to do |format| format.html { @@ -54,7 +56,6 @@ class TimelogController < ApplicationController @entry_count = scope.count @entry_pages = Paginator.new @entry_count, per_page_option, params['page'] @entries = scope.all( - :include => [:project, :activity, :user, {:issue => :tracker}], :limit => @entry_pages.per_page, :offset => @entry_pages.offset ) @@ -65,24 +66,20 @@ class TimelogController < ApplicationController format.api { @entry_count = scope.count @offset, @limit = api_offset_and_limit - @entries = scope.all( - :include => [:project, :activity, :user, {:issue => :tracker}], + @entries = scope.preload(:custom_values => :custom_field).all( :limit => @limit, :offset => @offset ) } format.atom { entries = scope.reorder("#{TimeEntry.table_name}.created_on DESC").all( - :include => [:project, :activity, :user, {:issue => :tracker}], :limit => Setting.feeds_limit.to_i ) render_feed(entries, :title => l(:label_spent_time)) } format.csv { # Export all entries - @entries = scope.all( - :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}] - ) + @entries = scope.all send_data(query_to_csv(@entries, @query, params), :type => 'text/csv; header=present', :filename => 'timelog.csv') } end -- 2.39.5