]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3790 use distinct keywords in db query instead of a set to remove duplicate...
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 22 Nov 2012 10:40:37 +0000 (11:40 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 22 Nov 2012 10:40:37 +0000 (11:40 +0100)
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/search_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/resource_index.rb

index af39a4fbd7cba5920eacad4798d3604ac3f6152c..174701c15c44c5dc4b99adad160a57e231069dee 100644 (file)
@@ -45,7 +45,7 @@ class Api::ResourcesController < Api::ApiController
       condition_values<<qualifiers
     end
     indexes = ResourceIndex.find(:all,
-                                 :select => 'resource_id,root_project_id,qualifier', # optimization to not load unused columns like 'kee'
+                                 :select => 'distinct(resource_id),root_project_id,qualifier', # optimization to not load unused columns like 'kee'
                                  :conditions => [conditions.join(' and ')].concat(condition_values),
                                  :order => 'name_size')
 
index 1d8c239389c35d3c22acda81b78ce090cdf77b92..cee1eda2f04cc825c778984b79c04e66c9dbffec 100644 (file)
@@ -47,7 +47,7 @@ class BulkDeletionController < ApplicationController
       end
       
       resource_ids = ResourceIndex.find(:all,
-                                        :select => 'resource_id',
+                                        :select => 'distinct(resource_id)',
                                         :conditions => [conditions, values],
                                         :order => 'name_size').map {|rid| rid.resource_id}.uniq
       
index bbc80bb41f802cf6f6d2a22a689a60359d0665ad..90277e674deb769d02ffa1d3ba4ea648fc1886e6 100644 (file)
@@ -33,12 +33,11 @@ class SearchController < ApplicationController
 
     key = search.downcase
     results = ResourceIndex.find(:all,
-                                 :select => 'resource_id,root_project_id,qualifier', # optimization to not load unused columns like 'kee'
+                                 :select => 'distinct(resource_id),root_project_id,qualifier', # optimization to not load unused columns like 'kee'
                                  :conditions => ["kee like ?", key + '%'],
                                  :order => 'name_size')
 
     results = select_authorized(:user, results)
-    results = Set.new(results) # do not want the same resource_index to appear many times in the result
     @total = results.size
 
     resource_ids=[]
index 6a3b4770d886fb4601c0b9408a404c9ea682a7c2..7f8b1b3c057664a9b72e13edf5e0c2dc068699db 100644 (file)
@@ -30,12 +30,4 @@ class ResourceIndex < ActiveRecord::Base
     root_project_id
   end
 
-  def eql?(another_resource_index)
-    resource_id == another_resource_index.resource_id && root_project_id == another_resource_index.root_project_id
-  end
-
-  def hash
-    [resource_id, root_project_id].hash
-  end
-
 end
\ No newline at end of file