Permalink
Browse files

Merge pull request #29 from sozialhelden/master

Better Performance when fetching objects from DB
  • Loading branch information...
2 parents befbf52 + 3c59ffe commit ca8b929811f7ba31bbfdcf610a987d4fae97ae1e @alexrabarts committed Mar 10, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/big_sitemap.rb
View
@@ -260,6 +260,9 @@ def generate_models
find_options[key] = options.delete(key)
end
+ # Keep the intial conditions for later user
+ conditions = find_options[:conditions]
+
primary_method = options.delete(:primary_column)
primary_column = "#{table_name(model)}.#{primary_method}"
@@ -287,7 +290,7 @@ def generate_models
if last_id && primary_column
find_options.update(:limit => limit, :offset => nil)
primary_column_value = escape_if_string last_id #escape '
- find_options.update(:conditions => [find_options[:conditions], "(#{primary_column} > #{primary_column_value})"].compact.join(' AND '))
+ find_options[:conditions] = [conditions, "(#{primary_column} > #{primary_column_value})"].compact.join(' AND ')
end
model.send(find_method, find_options).each do |record|

0 comments on commit ca8b929

Please sign in to comment.