diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-07-28 10:13:48 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-07-28 10:13:48 +0000 |
commit | ef8dd0f64b709c6695c67877f7bc1f750f5a9396 (patch) | |
tree | 659fa69ddad88547925f755ceaa353c3062a5795 /app/controllers | |
parent | 21fc903c0424c45c86430588b0ecb8f0cc589efa (diff) | |
download | redmine-ef8dd0f64b709c6695c67877f7bc1f750f5a9396.tar.gz redmine-ef8dd0f64b709c6695c67877f7bc1f750f5a9396.zip |
Preload some associations.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12044 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/timelog_controller.rb | 13 |
1 files 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 |