1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-30 12:19:38 +00:00

Improve custom fields list performance (#24587).

Patch by Thomas Löber.

git-svn-id: http://svn.redmine.org/redmine/trunk@16069 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2016-12-13 19:46:31 +00:00
parent 7b7a84c93a
commit 9d1d3b825f
2 changed files with 3 additions and 1 deletions

View File

@ -28,6 +28,8 @@ class CustomFieldsController < ApplicationController
respond_to do |format|
format.html {
@custom_fields_by_type = CustomField.all.group_by {|f| f.class.name }
@custom_fields_projects_count =
IssueCustomField.where(is_for_all: false).joins(:projects).group(:custom_field_id).count
}
format.api {
@custom_fields = CustomField.all

View File

@ -18,7 +18,7 @@
<td><%= checked_image custom_field.is_required? %></td>
<% if tab[:name] == 'IssueCustomField' %>
<td><%= checked_image custom_field.is_for_all? %></td>
<td><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
<td><%= l(:label_x_projects, :count => @custom_fields_projects_count[custom_field.id]) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
<% end %>
<td class="buttons">
<%= reorder_handle(custom_field, :url => custom_field_path(custom_field), :param => 'custom_field') %>