From 99f567a7e3d820b2730f51ddc9133ac68b11732b Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Thu, 26 Nov 2020 14:46:13 +0000 Subject: [PATCH] shorten long line of IssueQuery#joins_for_order_statement git-svn-id: http://svn.redmine.org/redmine/trunk@20497 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue_query.rb | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 93146b790..54a3c91e6 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -681,21 +681,35 @@ class IssueQuery < Query joins << "LEFT OUTER JOIN #{User.table_name} ON #{User.table_name}.id = #{queried_table_name}.assigned_to_id" end if order_options.include?('last_journal_user') - joins << "LEFT OUTER JOIN #{Journal.table_name} ON #{Journal.table_name}.id = (SELECT MAX(#{Journal.table_name}.id) FROM #{Journal.table_name}" + - " WHERE #{Journal.table_name}.journalized_type='Issue' AND #{Journal.table_name}.journalized_id=#{Issue.table_name}.id AND #{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})" + - " LEFT OUTER JOIN #{User.table_name} last_journal_user ON last_journal_user.id = #{Journal.table_name}.user_id"; + joins << + "LEFT OUTER JOIN #{Journal.table_name}" \ + " ON #{Journal.table_name}.id = (SELECT MAX(#{Journal.table_name}.id)" \ + " FROM #{Journal.table_name}" \ + " WHERE #{Journal.table_name}.journalized_type = 'Issue'" \ + " AND #{Journal.table_name}.journalized_id = #{Issue.table_name}.id " \ + " AND #{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})" \ + " LEFT OUTER JOIN #{User.table_name} last_journal_user" \ + " ON last_journal_user.id = #{Journal.table_name}.user_id" end if order_options.include?('versions') - joins << "LEFT OUTER JOIN #{Version.table_name} ON #{Version.table_name}.id = #{queried_table_name}.fixed_version_id" + joins << + "LEFT OUTER JOIN #{Version.table_name}" \ + " ON #{Version.table_name}.id = #{queried_table_name}.fixed_version_id" end if order_options.include?('issue_categories') - joins << "LEFT OUTER JOIN #{IssueCategory.table_name} ON #{IssueCategory.table_name}.id = #{queried_table_name}.category_id" + joins << + "LEFT OUTER JOIN #{IssueCategory.table_name}" \ + " ON #{IssueCategory.table_name}.id = #{queried_table_name}.category_id" end if order_options.include?('trackers') - joins << "LEFT OUTER JOIN #{Tracker.table_name} ON #{Tracker.table_name}.id = #{queried_table_name}.tracker_id" + joins << + "LEFT OUTER JOIN #{Tracker.table_name}" \ + " ON #{Tracker.table_name}.id = #{queried_table_name}.tracker_id" end if order_options.include?('enumerations') - joins << "LEFT OUTER JOIN #{IssuePriority.table_name} ON #{IssuePriority.table_name}.id = #{queried_table_name}.priority_id" + joins << + "LEFT OUTER JOIN #{IssuePriority.table_name}" \ + " ON #{IssuePriority.table_name}.id = #{queried_table_name}.priority_id" end end -- 2.39.5