Skip to content

Instantly share code, notes, and snippets.

@BananaNeil
Created June 18, 2015 21:36
Show Gist options
  • Save BananaNeil/dee8b84519372894f50a to your computer and use it in GitHub Desktop.
Save BananaNeil/dee8b84519372894f50a to your computer and use it in GitHub Desktop.
Destroy duplicate mobile notifications
bill_ids = Persistence::MobileNotification.group(:bill_id).count.select{|k,v| v > 1}.map(&:first)
Persistence::Bill.where(id: bill_ids, congress: 114).each do |b|
notifications = b.mobile_notifications
puts b.bill_id.green
notifications.each_with_index {|n, i| puts "#{i}) #{n.message.strip}".yellow}
print 'Keep which one? '.light_blue
(notifications - [notifications[gets.strip.to_i]]).each {|n| puts "DESTROYING #{n.message}".red;n.destroy}
end;nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment