Mercurial > hg > soundsoftware-site
comparison app/controllers/search_controller.rb @ 499:85fd403a7daa cannam
Merge
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Wed, 13 Jul 2011 12:46:00 +0100 |
parents | 87bfac1079fd |
children | 851510f1b535 |
comparison
equal
deleted
inserted
replaced
497:f6ed606887bc | 499:85fd403a7daa |
---|---|
67 | 67 |
68 if !@tokens.empty? | 68 if !@tokens.empty? |
69 # no more than 5 tokens to search for | 69 # no more than 5 tokens to search for |
70 @tokens.slice! 5..-1 if @tokens.size > 5 | 70 @tokens.slice! 5..-1 if @tokens.size > 5 |
71 | 71 |
72 @project_matches = [] | |
72 @results = [] | 73 @results = [] |
73 @results_by_type = Hash.new {|h,k| h[k] = 0} | 74 @results_by_type = Hash.new {|h,k| h[k] = 0} |
74 | 75 |
75 limit = 10 | 76 limit = 10 |
76 @scope.each do |s| | 77 @scope.each do |s| |
80 :limit => (limit+1), | 81 :limit => (limit+1), |
81 :offset => offset, | 82 :offset => offset, |
82 :before => params[:previous].nil?) | 83 :before => params[:previous].nil?) |
83 @results += r | 84 @results += r |
84 @results_by_type[s] += c | 85 @results_by_type[s] += c |
86 if s == 'projects' | |
87 r, c = s.singularize.camelcase.constantize.search(@tokens, nil, | |
88 :all_words => @all_words, | |
89 :titles_only => 1) | |
90 @project_matches += r | |
91 end | |
85 end | 92 end |
86 @results = @results.sort {|a,b| b.event_datetime <=> a.event_datetime} | 93 @results = @results.sort {|a,b| b.event_datetime <=> a.event_datetime} |
87 if params[:previous].nil? | 94 if params[:previous].nil? |
88 @pagination_previous_date = @results[0].event_datetime if offset && @results[0] | 95 @pagination_previous_date = @results[0].event_datetime if offset && @results[0] |
89 if @results.size > limit | 96 if @results.size > limit |