summaryrefslogtreecommitdiffstats
path: root/app/controllers/search_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-20 17:26:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-20 17:26:07 +0000
commitbe2b8a62f4d0d8bf413a5583fe644bd41a8ebf04 (patch)
tree95fe7f273935739e1ffa82be16cee93927a4c054 /app/controllers/search_controller.rb
parent83baccb71ac0e609ce72ebf322f73884548a9ba5 (diff)
downloadredmine-be2b8a62f4d0d8bf413a5583fe644bd41a8ebf04.tar.gz
redmine-be2b8a62f4d0d8bf413a5583fe644bd41a8ebf04.zip
Search engine: display total results count (#906) and count by result type.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1681 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r--app/controllers/search_controller.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index d4ef01bf8..50e42f088 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -72,15 +72,20 @@ class SearchController < ApplicationController
@tokens.slice! 5..-1 if @tokens.size > 5
# strings used in sql like statement
like_tokens = @tokens.collect {|w| "%#{w.downcase}%"}
+
@results = []
+ @results_by_type = Hash.new {|h,k| h[k] = 0}
+
limit = 10
@scope.each do |s|
- @results += s.singularize.camelcase.constantize.search(like_tokens, projects_to_search,
+ r, c = s.singularize.camelcase.constantize.search(like_tokens, projects_to_search,
:all_words => @all_words,
:titles_only => @titles_only,
:limit => (limit+1),
:offset => offset,
:before => params[:previous].nil?)
+ @results += r
+ @results_by_type[s] += c
end
@results = @results.sort {|a,b| b.event_datetime <=> a.event_datetime}
if params[:previous].nil?