Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Finished fixing sql search with total_entries

  • Loading branch information...
commit 592edcf07159d26cedc0a4b5ceddfd291fa6b38f 1 parent db82906
@JangoSteve JangoSteve authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 lib/search_engine/sql.rb
View
15 lib/search_engine/sql.rb
@@ -50,8 +50,17 @@ def self.add_searching_to(model)
end
def self.search(query, options = {})
- SearchEngine.searchable_models.map {|model|
- model.to_s.constantize.search(query, options)
- }.flatten
+ SearchEngine.searchable_models.inject(SearchCollection.new) {|collection, model|
+ results = model.to_s.constantize.search(query, options)
+ collection.total_entries += results.total_entries
+ collection.concat(results)
+ }
+ end
+
+ class SearchCollection < Array
+ attr_accessor :total_entries
+ def initialize
+ self.total_entries = 0
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.