Skip to content

Instantly share code, notes, and snippets.

@dce
Created June 16, 2009 14:59
Show Gist options
  • Save dce/130723 to your computer and use it in GitHub Desktop.
Save dce/130723 to your computer and use it in GitHub Desktop.
dups = Notification.undelivered.all(:select => "user_id, about_id, about_type, COUNT(*) AS dup_count",
:group => "user_id, about_id, about_type HAVING dup_count > 1")
dups.each do |dup|
notes = Notification.find_all_by_user_id_and_about_id_and_about_type(dup.user_id, dup.about_id, dup.about_type)
notes[1..-1].each(&:destroy)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment