]> source.dussan.org Git - redmine.git/commitdiff
shorten long line of IssueQuery#joins_for_order_statement
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 26 Nov 2020 14:46:13 +0000 (14:46 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Thu, 26 Nov 2020 14:46:13 +0000 (14:46 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@20497 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb

index 93146b790143e9c15bc305dc189781b247098fc4..54a3c91e6d4b688326bbabb1ae380df03b06bbb2 100644 (file)
@@ -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