summaryrefslogtreecommitdiffstats
path: root/app/models/issue_query.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-18 12:54:22 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-18 12:54:22 +0000
commitaa354e62751670a1c2c6752cdfe9b8d6fb6c0bae (patch)
tree09bb080786454e4608871787765407e546221134 /app/models/issue_query.rb
parent2c70d9e9886ebbd0924cd543f399788da9df21ca (diff)
downloadredmine-aa354e62751670a1c2c6752cdfe9b8d6fb6c0bae.tar.gz
redmine-aa354e62751670a1c2c6752cdfe9b8d6fb6c0bae.zip
Don't join all associations by default (#24865).
git-svn-id: http://svn.redmine.org/redmine/trunk@16221 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue_query.rb')
-rw-r--r--app/models/issue_query.rb21
1 files changed, 18 insertions, 3 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index 61750557a..9613b2ae2 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -273,9 +273,9 @@ class IssueQuery < Query
limit(options[:limit]).
offset(options[:offset])
- scope = scope.preload(:custom_values)
- if has_column?(:author)
- scope = scope.preload(:author)
+ scope = scope.preload([:tracker, :priority, :author, :assigned_to, :fixed_version, :category] & columns.map(&:name))
+ if has_custom_field_column?
+ scope = scope.preload(:custom_values)
end
issues = scope.to_a
@@ -513,6 +513,21 @@ class IssueQuery < Query
if order_options.include?('authors')
joins << "LEFT OUTER JOIN #{User.table_name} authors ON authors.id = #{queried_table_name}.author_id"
end
+ if order_options.include?('users')
+ joins << "LEFT OUTER JOIN #{User.table_name} ON #{User.table_name}.id = #{queried_table_name}.assigned_to_id"
+ end
+ if order_options.include?('fixed_version')
+ joins << "LEFT OUTER JOIN #{Version.table_name} ON #{Version.table_name}.id = #{queried_table_name}.fixed_version_id"
+ end
+ if order_options.include?('category')
+ joins << "LEFT OUTER JOIN #{IssueCategory.table_name} ON #{IssueCategory.table_name}.id = #{queried_table_name}.category_id"
+ end
+ if order_options.include?('tracker')
+ joins << "LEFT OUTER JOIN #{Tracker.table_name} ON #{Tracker.table_name}.id = #{queried_table_name}.tracker_id"
+ end
+ if order_options.include?('enumeration')
+ joins << "LEFT OUTER JOIN #{IssuePriority.table_name} ON #{IssuePriority.table_name}.id = #{queried_table_name}.priority_id"
+ end
end
joins.any? ? joins.join(' ') : nil