alexrabarts/big_sitemap — Issue #21: suggestions
Author: inspire22
Created: 2011-11-01 00:46:48+00:00
State: open

phew, that was a lot of work

seems like find_in_batches needs a sub iterator, as the first arg returned is an array of the first 1k results:

Group.where("deleted=0 AND id > #{get_last_id('item')}").find_in_batches do |set|
set.each do |i|
add i.full_url(:app), :change_frequency => 'never', :last_modified => i.updated_at
end
end

rewriting get_last_id was kind of a pain:
def get_last_id(filename)
path = "#{File.expand_path('../..',__FILE__)}/public/sitemaps/sitemap_#{filename}*.{xml,xml.gz}"
#puts "path is #{path}"
v=Dir[path].map do |file|
file.to_s.scan(/#{filename}_(.+).xml/).flatten.last.to_i
end.sort.last
puts "starting from #{filename} id #{v}"
v
end

My document_root directory is created, but the files aren't written inside it? I'll look into it more later I guess