add fix script to remove expunged posts from iqdb
This commit is contained in:
27
script/fixes/041_remove_expunged_posts_from_iqdb.rb
Normal file
27
script/fixes/041_remove_expunged_posts_from_iqdb.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||
|
||||
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||
|
||||
CurrentUser.user = User.admins.first
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
n = 1
|
||||
max = Post.maximum(:id)
|
||||
interval = 10_000
|
||||
|
||||
while n <= max
|
||||
all = n.upto(n + interval).to_a
|
||||
present = Post.where("id between ? and ?", n, n + interval).pluck(:id)
|
||||
missing = present - ids
|
||||
missing.each do |x|
|
||||
if x <= max
|
||||
puts "expunging #{x}"
|
||||
Post.remove_iqdb(x)
|
||||
end
|
||||
end
|
||||
|
||||
n += interval
|
||||
max = Post.maximum(:id)
|
||||
end
|
||||
Reference in New Issue
Block a user