Skip to content

Instantly share code, notes, and snippets.

@ewpeters
Created December 17, 2012 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ewpeters/4321312 to your computer and use it in GitHub Desktop.
Save ewpeters/4321312 to your computer and use it in GitHub Desktop.
#!/usr/bin/env script/minrunner
MemberVisitor.find(:all, :conditions => "snap_user_id is not null and destination_id is null").each do |member|
snap_acct = Snap::Member.find(member.snap_user_id) rescue nil
if snap_acct && snap_acct.phone_number.present?
dest = Destination.find_by_ANI(snap_acct.phone_number)
if dest
$stdout.puts "#{member.id},#{dest.id}"
member.destinations << dest unless member.destinations.include?(dest)
member.create_snap_destination
member.save
else
$stderr.puts "Couldnt find destination #{snap_acct.phone_number}"
end
else
$stderr.puts "No acct or Phone number for #{member.snap_user_id}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment