Dedupe follows

This commit is contained in:
Kyle Drake 2015-08-13 19:01:13 -05:00
parent 1efe0d486b
commit b5920d8ba8
2 changed files with 22 additions and 0 deletions

View file

@ -240,6 +240,19 @@ task :prime_site_files => [:environment] do
end
end
desc 'dedupe_follows'
task :dedupe_follows => [:environment] do
follows = Follow.all
deduped_follows = Follow.all.uniq {|f| "#{f.site_id}_#{f.actioning_site_id}"}
follows.each do |follow|
unless deduped_follows.include?(follow)
puts "deleting dedupe: #{follow.inspect}"
follow.delete
end
end
end
=begin
desc 'Update screenshots'
task :update_screenshots => [:environment] do

View file

@ -0,0 +1,9 @@
Sequel.migration do
up {
DB['alter table follows add constraint one_follow_per_site unique (site_id, actioning_site_id)'].first
}
down {
DB['alter table follows drop constraint one_follow_per_site'].first
}
end