From: Fabrice Bellingard Date: Wed, 11 Jul 2012 15:27:12 +0000 (+0200) Subject: SONAR-2614 Use the ResourceIndex to search for deletable resources X-Git-Tag: 3.2~115 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=abfd8acf57b61da9b4d1a50993a8111493d98602;p=sonarqube.git SONAR-2614 Use the ResourceIndex to search for deletable resources --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb index e7a1619d83f..010a4d31403 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb @@ -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