From: Julien Lancelot Date: Thu, 22 Nov 2012 09:04:23 +0000 (+0100) Subject: SONAR-3790 Remove duplicate resources in search results X-Git-Tag: 3.4~305 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=86f812f12f3a9ea259e581f82887c48dc466ff79;p=sonarqube.git SONAR-3790 Remove duplicate resources in search results --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/search_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/search_controller.rb index c4946d1f4ea..bbc80bb41f8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/search_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/search_controller.rb @@ -17,6 +17,8 @@ # License along with Sonar; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 # +require "set" + class SearchController < ApplicationController SECTION=Navigation::SECTION_HOME @@ -36,17 +38,18 @@ class SearchController < ApplicationController :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=[] @resource_indexes_by_qualifier={} results.each do |resource_index| qualifier = fix_qualifier(resource_index.qualifier) - @resource_indexes_by_qualifier[qualifier]||=[] - array=@resource_indexes_by_qualifier[qualifier] - if array.size