From 86f812f12f3a9ea259e581f82887c48dc466ff79 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 22 Nov 2012 10:04:23 +0100 Subject: [PATCH] SONAR-3790 Remove duplicate resources in search results --- .../WEB-INF/app/controllers/search_controller.rb | 13 ++++++++----- .../webapp/WEB-INF/app/models/resource_index.rb | 9 +++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) 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