Created
August 28, 2015 14:55
-
-
Save Raven24/3f61b2cc6e91091728a1 to your computer and use it in GitHub Desktop.
find duplicates + how many
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count = Pod.arel_table[:host].count.as("dup_count") | |
col = Arel::Nodes::SqlLiteral.new("dup_count") | |
Pod. | |
group(Pod.arel_table[:host]). | |
having(col.gt(1)).order(col.desc). | |
pluck(count.to_sql, :host). | |
each do |pod| | |
pp pod | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment