diff options
author | francis <francis> | 2008-07-28 15:10:23 +0000 |
---|---|---|
committer | francis <francis> | 2008-07-28 15:10:23 +0000 |
commit | eb1a96628ed541f778a7c4cbcd56246f3ee56925 (patch) | |
tree | c9ff0108cd8eb726de2bdd94771c2ee2150b65c1 | |
parent | 02ebba5c73136a40f41c1e6ae685d556363aca36 (diff) |
Updates from git.
-rw-r--r-- | vendor/plugins/acts_as_xapian/README.txt | 2 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/vendor/plugins/acts_as_xapian/README.txt b/vendor/plugins/acts_as_xapian/README.txt index af945a8d4..c52734e40 100644 --- a/vendor/plugins/acts_as_xapian/README.txt +++ b/vendor/plugins/acts_as_xapian/README.txt @@ -188,7 +188,7 @@ To perform a query from code call ActsAsXapian::Search.new. This takes in turn: And then a hash of options: * :offset - Offset of first result (default 0) -* :limit - Number of results per page (default -1, all) +* :limit - Number of results per page * :sort_by_prefix - Optionally, prefix of value to sort by, otherwise sort by relevance * :sort_by_ascending - Default true, set to false for descending sort * :collapse_by_prefix - Optionally, prefix of value to collapse by (i.e. only return most relevant result from group) diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb index e2e555cfd..47a33f713 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -204,8 +204,11 @@ module ActsAsXapian # Set self.query before calling this def initialize_query(options) #raise options.to_yaml + offset = options[:offset] || 0; offset = offset.to_i - limit = options[:limit] || -1; limit = limit.to_i # -1 means all matches? + limit = options[:limit] + raise "please specifiy maximum number of results to return with parameter :limit" if not limit + limit = limit.to_i sort_by_prefix = options[:sort_by_prefix] || nil sort_by_ascending = options[:sort_by_ascending] || true collapse_by_prefix = options[:collapse_by_prefix] || nil @@ -278,7 +281,7 @@ module ActsAsXapian # for each class, look up all ids chash = {} for cls, ids in lhash - conditions = [ "#{cls.constantize.table_name}.id in (?)", ids ] + conditions = [ "#{cls.constantize.table_name}.#{cls.constantize.primary_key} in (?)", ids ] found = cls.constantize.find(:all, :conditions => conditions, :include => cls.constantize.xapian_options[:eager_load]) for f in found chash[[cls, f.id]] = f |