From a10b584e060f42b1c3e325e07853f643681d5b32 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 26 Nov 2012 10:11:19 +0100 Subject: [PATCH] SONAR-3805 Cannot load the project bulk deletion page when there are more than 1,000 projects --- .../controllers/bulk_deletion_controller.rb | 19 ++++++++++--------- .../main/webapp/WEB-INF/app/models/project.rb | 1 + 2 files changed, 11 insertions(+), 9 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 9cac2bb2a87..e6ba328970d 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,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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb index 902ad57de75..e37e69b3c8a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb @@ -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 -- 2.39.5