]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3805 Cannot load the project bulk deletion page when there are more than 1...
authorJulien Lancelot <julien.lancelot@gmail.com>
Mon, 26 Nov 2012 09:11:19 +0000 (10:11 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Mon, 26 Nov 2012 09:11:19 +0000 (10:11 +0100)
sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/project.rb

index 9cac2bb2a8732bc944f497f35467a6f58c58a686..e6ba328970df84071561c58c6a052615c8f5f6fb 100644 (file)
@@ -39,19 +39,20 @@ class BulkDeletionController < ApplicationController
       @selected_tab = 'TRK' unless @tabs.include?(@selected_tab)
       
       # Search for resources
-      conditions = "qualifier=:qualifier"
+      conditions = "resource_index.qualifier=:qualifier"
       values = {:qualifier => @selected_tab}
       if params[:name_filter] && !params[:name_filter].blank?
-        conditions += " AND kee LIKE :kee"
+        conditions += " AND resource_index.kee LIKE :kee"
         values[:kee] = params[:name_filter].strip.downcase + '%'
       end
-      
-      resource_ids = ResourceIndex.find(:all,
-                                        :select => 'distinct(resource_id),name_size',
-                                        :conditions => [conditions, values],
-                                        :order => 'name_size').map {|rid| rid.resource_id}.uniq
-      
-      @resources = Project.find(:all, :conditions => ['id in (?) and enabled=?', resource_ids, true], :order => 'name ASC')
+
+      conditions += " AND projects.enabled=:enabled"
+      values[:enabled] = true
+      @resources = Project.find(:all,
+                                :select => 'distinct(resource_index.resource_id),projects.id,projects.name,projects.kee',
+                                :conditions => [conditions, values],
+                                :joins => :resource_index,
+                                :order => 'projects.name ASC')
     end
   end
   
index 902ad57de758609cd3b8d419f8f192c2182abe40..e37e69b3c8ad06b52d492bfae1dc222c7285eb08 100644 (file)
@@ -33,6 +33,7 @@ class Project < ActiveRecord::Base
   belongs_to :person, :class_name => 'Project', :foreign_key => 'person_id'
   has_many :authors, :foreign_key => 'person_id', :dependent => :delete_all
   has_one :index, :class_name => 'ResourceIndex', :foreign_key => 'resource_id', :conditions => 'position=0', :select => 'kee'
+  has_many :resource_index, :foreign_key => 'resource_id'
 
   def self.by_key(k)
     begin