Skip to content

Instantly share code, notes, and snippets.

@marclove
Forked from jnunemaker/remove_key.rake
Created February 3, 2010 05:10
Show Gist options
  • Save marclove/293344 to your computer and use it in GitHub Desktop.
Save marclove/293344 to your computer and use it in GitHub Desktop.
namespace :harmony do
desc "Munges the data"
task :munge => :environment do
docs_with_publish = Item.collection.find({'publish' => {'$exists' => true}}).to_a
puts "Item count: #{Item.count}"
puts "Items with publish key: #{docs_with_publish.size}"
docs_with_publish.each do |hash|
hash.delete('publish')
Item.collection.save(hash)
end
activities_with_thumbnail = Activity.collection.find({'source.thumbnail' => {'$exists' => true}}).to_a
puts "Activity count: #{Activity.count}"
puts "Activites with thumbnail: #{activities_with_thumbnail.size}"
activities_with_thumbnail.each do |hash|
hash['source'].delete('thumbnail')
Activity.collection.save(hash)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment