]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2614 Use the ResourceIndex to search for deletable resources
authorFabrice Bellingard <bellingard@gmail.com>
Wed, 11 Jul 2012 15:27:12 +0000 (17:27 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Thu, 12 Jul 2012 08:33:31 +0000 (10:33 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb

index e7a1619d83fd574c255be94f38a790519bc1c77e..010a4d31403d991e161313a58f17ad7df5c2952f 100644 (file)
@@ -39,9 +39,9 @@ class BulkDeletionController < ApplicationController
       @should_display_views_tab = Project.count(:all, :conditions => {:qualifier => 'VW'}) > 0
       @should_display_devs_tab = Project.count(:all, :conditions => {:qualifier => 'DEV'}) > 0
       
-      # Search for resources
-      conditions = "scope=:scope AND qualifier=:qualifier"
-      values = {:scope => 'PRJ'}
+      # Search for resources      
+      values = {}
+      conditions = "qualifier=:qualifier"
       qualifier = 'TRK'
       if @selected_tab == 'views'
         qualifier = 'VW'
@@ -50,11 +50,16 @@ class BulkDeletionController < ApplicationController
       end
       values[:qualifier] = qualifier
       if params[:name_filter]
-        conditions += " AND name LIKE :name"
-        values[:name] = '%' + params[:name_filter].strip + '%'
+        conditions += " AND kee LIKE :kee"
+        values[:kee] = '%' + params[:name_filter].strip.downcase + '%'
       end
-        
-      @resources = Project.find(:all, :conditions => [conditions, values], :order => 'name ASC')
+      
+      resource_ids = ResourceIndex.find(:all,
+                                        :select => 'resource_id',
+                                        :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')
     end
   end