Modified: trunk/app/controllers/search_controller.rb (2226 => 2227)
--- trunk/app/controllers/search_controller.rb 2009-06-11 14:19:30 UTC (rev 2226)
+++ trunk/app/controllers/search_controller.rb 2009-06-11 16:05:21 UTC (rev 2227)
@@ -152,23 +152,31 @@
models = categories.map do |category| eval(category.singularize.camelize) end
- @results = User.multi_solr_search(@query, :limit => 100, :models => models).results
-
- @total_count = @results.length
+ @total_count = 0
@infos = []
models.each do |model|
- model_results = @results.select do |r| r.instance_of?(model) end
+ model_results = model.find_by_solr(@query, :limit => 10)
+ model_count = model_results.total
- if (model_results.length > 0)
+ search_type = model.name.downcase.pluralize
+
+ Conf.model_aliases.each do |k,v|
+ search_type = k.downcase.pluralize if model.name == v
+ end
+
+ if (model_results.results.length > 0)
@infos.push({
+ :search_type => search_type,
:model => model,
- :results => model_results,
- :total_count => model.count_by_solr(@query)
+ :results => model_results.results,
+ :total_count => model_count
})
end
+
+ @total_count += model_count
end
end
Modified: trunk/app/views/search/show.rhtml (2226 => 2227)
--- trunk/app/views/search/show.rhtml 2009-06-11 14:19:30 UTC (rev 2226)
+++ trunk/app/views/search/show.rhtml 2009-06-11 16:05:21 UTC (rev 2227)
@@ -2,13 +2,8 @@
<%= render :partial => 'extra_search_help' %>
-<h1>Search Results</h1>
+<h1>Search results for "<%= h @query -%>"</h1>
-<p class="box_standout" style="font-size: 108%; margin-bottom: 1em;">
- <b>Search keywords: </b>
- <%= h @query -%>
-</p>
-
<% if @total_count == 0 %>
<p class="none_text">No search results.</p>
@@ -21,10 +16,22 @@
<div id="tabsContainer" class="tabsContainer"></div>
<% @infos.each do |info| %>
+
+ <% name = visible_name(info[:model]).pluralize
+ count = info[:results].length
+ total = info[:total_count] -%>
+
<div class="tabContainer">
- <div class="tabTitle"><%= visible_name(info[:model]).pluralize %> (<%= info[:results].length -%><% if info[:results].length < info[:total_count] %> of <%= info[:total_count ] -%><% end %>)</div>
+ <div class="tabTitle"><%= name %> (<%= count -%><% if count < total %> of <%= total -%><% end %>)</div>
<div class="tabContent">
- <%= render :partial => "#{info[:model].to_s.underscore.pluralize}/table", :locals => { :collection => info[:results], :query => @query } %>
+
+ <% if count < total %>
+ <p class="box_standout" style="font-size: 108%; margin-bottom: 1em; margin-top: 0.6em;"><b>
+ There are more results than shown here. <a href="" search_path + "?type=#{info[:search_type]}&query=" + params[:query] -%>">See all <%= name %> results</a> for this query.
+ </b></p>
+ <% end %>
+
+ <%= render :partial => "#{info[:model].to_s.underscore.pluralize}/table", :locals => { :collection => info[:results], :query => @query } %>
</div>
</div>
<% end %>