diff --git a/script/fixes/041_remove_expunged_posts_from_iqdb.rb b/script/fixes/041_remove_expunged_posts_from_iqdb.rb new file mode 100644 index 000000000..e67fdec76 --- /dev/null +++ b/script/fixes/041_remove_expunged_posts_from_iqdb.rb @@ -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