From 27f53fa5db015ca47680e1dda26ad1ef04b27e73 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Tue, 3 May 2016 12:30:34 -0700 Subject: [PATCH] add fix script to remove expunged posts from iqdb --- .../041_remove_expunged_posts_from_iqdb.rb | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 script/fixes/041_remove_expunged_posts_from_iqdb.rb 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