mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Dedupe follows
This commit is contained in:
parent
1efe0d486b
commit
b5920d8ba8
2 changed files with 22 additions and 0 deletions
13
Rakefile
13
Rakefile
|
@ -240,6 +240,19 @@ task :prime_site_files => [:environment] do
|
||||||
end
|
end
|
||||||
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
|
=begin
|
||||||
desc 'Update screenshots'
|
desc 'Update screenshots'
|
||||||
task :update_screenshots => [:environment] do
|
task :update_screenshots => [:environment] do
|
||||||
|
|
9
migrations/073_add_follow_uniqueness.rb
Normal file
9
migrations/073_add_follow_uniqueness.rb
Normal 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
|
Loading…
Add table
Reference in a new issue