]> source.dussan.org Git - redmine.git/commitdiff
Use regular AR query instead of raw SQL.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 23 Oct 2014 17:22:32 +0000 (17:22 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 23 Oct 2014 17:22:32 +0000 (17:22 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13496 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/tracker.rb

index b4f22c811bd1dbb6a5f9213deace09cc828e2b58..bf8a08f20fd2f716ab20dab3e20e6586a22910ca 100644 (file)
@@ -59,11 +59,8 @@ class Tracker < ActiveRecord::Base
       return []
     end
 
-    ids = WorkflowTransition.
-            connection.select_rows("SELECT DISTINCT old_status_id, new_status_id FROM #{WorkflowTransition.table_name} WHERE tracker_id = #{id} AND type = 'WorkflowTransition'").
-            flatten.
-            uniq
-    @issue_statuses = IssueStatus.where(:id => ids).to_a.sort
+    status_ids = WorkflowTransition.where(:tracker_id => id).uniq.pluck(:old_status_id, :new_status_id).flatten.uniq
+    @issue_statuses = IssueStatus.where(:id => status_ids).to_a.sort
   end
 
   def disabled_core_fields