OSDN Git Service

Performance improvement on workflow setup screen.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 7 Dec 2007 11:19:30 +0000 (11:19 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 7 Dec 2007 11:19:30 +0000 (11:19 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@957 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/roles_controller.rb
app/views/roles/workflow.rhtml
db/migrate/085_add_role_tracker_old_status_index_to_workflows.rb [new file with mode: 0644]

index 3b5766a..a8a31cd 100644 (file)
@@ -94,7 +94,7 @@ class RolesController < ApplicationController
     end
     @roles = Role.find(:all, :order => 'builtin, position')
     @trackers = Tracker.find(:all, :order => 'position')
-    @statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position')
+    @statuses = IssueStatus.find(:all, :order => 'position')
   end
   
   def report    
index 2bc2abd..0a43574 100644 (file)
        
        <% for old_status in @statuses %>
                <tr>
-               <td><%= old_status.name %></td>         
-               <% for new_status in @statuses %>
+               <td><%= old_status.name %></td>
+               <% new_status_ids_allowed = old_status.find_new_statuses_allowed_to(@role, @tracker).collect(&:id) -%>
+               <% for new_status in @statuses -%>
                        <td align="center">
-      
-     <input type="checkbox"
+      <input type="checkbox"
       name="issue_status[<%= old_status.id %>][]"
       value="<%= new_status.id %>"
-      <%if old_status.new_statuses_allowed_to(@role, @tracker).include? new_status%>checked="checked"<%end%>
-      >                        
+      <%= 'checked="checked"' if new_status_ids_allowed.include? new_status.id %>>                     
                        </td>
-               <% end %>               
-               
+               <% end -%>
                </tr>
        <% end %>
        </table>
diff --git a/db/migrate/085_add_role_tracker_old_status_index_to_workflows.rb b/db/migrate/085_add_role_tracker_old_status_index_to_workflows.rb
new file mode 100644 (file)
index 0000000..523cf09
--- /dev/null
@@ -0,0 +1,9 @@
+class AddRoleTrackerOldStatusIndexToWorkflows < ActiveRecord::Migration
+  def self.up
+    add_index :workflows, [:role_id, :tracker_id, :old_status_id], :name => :workflows_role_tracker_old_status
+  end
+
+  def self.down
+    remove_index :workflows, :name => :workflows_role_tracker_old_status
+  end
+end