diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-10-13 10:04:59 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-10-13 10:04:59 +0000 |
commit | 7bea176cdb745aa5351c3836afc89ee339052125 (patch) | |
tree | 1a0e0ea0d56260bd7e26955dcd304eefb46cb0d7 /app/helpers | |
parent | 60d6e169781e8aa40aab42c5df1f806f646d8bd0 (diff) | |
download | redmine-7bea176cdb745aa5351c3836afc89ee339052125.tar.gz redmine-7bea176cdb745aa5351c3836afc89ee339052125.zip |
Avoid lots of CustomField.find_by_id calls when displaying an issue history with custom fields (#15072).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12217 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/issues_helper.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index bc7fbab85..614c2f90d 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -261,23 +261,23 @@ module IssuesHelper values_by_field = {} details.each do |detail| if detail.property == 'cf' - field_id = detail.prop_key - field = CustomField.find_by_id(field_id) + field = detail.custom_field if field && field.multiple? - values_by_field[field_id] ||= {:added => [], :deleted => []} + values_by_field[field] ||= {:added => [], :deleted => []} if detail.old_value - values_by_field[field_id][:deleted] << detail.old_value + values_by_field[field][:deleted] << detail.old_value end if detail.value - values_by_field[field_id][:added] << detail.value + values_by_field[field][:added] << detail.value end next end end strings << show_detail(detail, no_html, options) end - values_by_field.each do |field_id, changes| - detail = JournalDetail.new(:property => 'cf', :prop_key => field_id) + values_by_field.each do |field, changes| + detail = JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s) + detail.instance_variable_set "@custom_field", field if changes[:added].any? detail.value = changes[:added] strings << show_detail(detail, no_html, options) @@ -320,7 +320,7 @@ module IssuesHelper old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank? end when 'cf' - custom_field = CustomField.find_by_id(detail.prop_key) + custom_field = detail.custom_field if custom_field multiple = custom_field.multiple? label = custom_field.name |