From abfd8acf57b61da9b4d1a50993a8111493d98602 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Wed, 11 Jul 2012 17:27:12 +0200 Subject: [PATCH] SONAR-2614 Use the ResourceIndex to search for deletable resources --- .../controllers/bulk_deletion_controller.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 -- 2.39.5