Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created February 26, 2018 21:24
Show Gist options
  • Select an option

  • Save ahoward/5f3be639682004ab1e44135bd7c059a8 to your computer and use it in GitHub Desktop.

Select an option

Save ahoward/5f3be639682004ab1e44135bd7c059a8 to your computer and use it in GitHub Desktop.
=begin
1) save this file in the rails_root as 'a.rb'
2) run
~> ./bin/rails runner a.rb
3) it should print out something like
DESTROY: Audience[account: "control-group", name: "sample", id: 5a87337cbfe1a449740024db]
ORPHAN: Audience[account: "wiland", name: "SpotRight Testing (lrcawarriors)", id: 5a036a72bfe1a4b843000673]
ORPHAN: Audience[account: "wiland", name: "SpotRight Testing (lrcawarriors)", id: 5a038d67bfe1a4e6c700003f]
ORPHAN: Audience[account: "control-group", name: "sample", id: 5a87337cbfe1a449740024db]
=end
show = proc do |a|
"#{ a.class.name }[account: #{ a.account.slug.inspect }, name: #{ a.name.inspect }, id: #{ a.id }]"
end
audience = Audience.where(:id => '5a87337cbfe1a449740024db').first
audience.destroy
puts "DESTROY: #{ show[audience] }"
puts
Audience.all.each do |doc|
if doc.analysis.blank?
puts "ORPHAN: #{ show[doc] }"
end
end
Audience::Distribution.all.each do |doc|
if doc.analysis.blank?
puts "ORPHAN: #{ show[doc] }"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment