# 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
: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<MAX_RESULTS
- resource_ids<<resource_index.resource_id
- array<<resource_index
+ @resource_indexes_by_qualifier[qualifier] ||= []
+ array = @resource_indexes_by_qualifier[qualifier]
+ if array.size < MAX_RESULTS
+ resource_ids << resource_index.resource_id
+ array << resource_index
end
end
def resource_id_for_authorization
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