rubocop: fix various style issues.

This commit is contained in:
evazion
2019-12-22 21:23:37 -06:00
parent 09f6a84660
commit 309821bf73
288 changed files with 912 additions and 962 deletions
Regular → Executable
View File
Regular → Executable
+2 -2
View File
@@ -7,7 +7,7 @@ Post.where("image_width > 850").find_each do |post|
next
end
if !File.exists?(post.file_path)
if !File.exist?(post.file_path)
puts "NOT FOUND: #{post.id}"
next
end
@@ -19,7 +19,7 @@ Post.where("image_width > 850").find_each do |post|
resize = false
if !File.exists?(post.large_file_path)
if !File.exist?(post.large_file_path)
puts "LARGE NOT FOUND: #{post.id}"
resize = true
end
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
+5 -5
View File
@@ -9,26 +9,26 @@ Comment.find_each do |comment|
puts "deleting comment #{comment.id}"
comment.destroy
end
end ; true
end; true
Ban.find_each do |ban|
puts "updating ban for user #{ban.user.id}"
ban.user.update_attribute(:is_banned, true)
end ; true
end; true
ArtistVersion.update_all "is_banned = false"
Artist.where("is_banned = true").find_each do |artist|
puts "updating artist #{artist.id}"
artist.versions.last.update_column(:is_banned, true)
end ; true
end; true
danbooru_conn = PGconn.connect(dbname: 'danbooru')
danbooru2_conn = PGconn.connect(dbname: "danbooru2")
danbooru_conn.exec("set statement_timeout = 0")
danbooru_conn.exec( "SELECT * FROM comments WHERE id < 29130" ) do |result|
danbooru_conn.exec("SELECT * FROM comments WHERE id < 29130") do |result|
result.each do |row|
# puts row["id"], row["created_at"], row["post_id"], row["user_id"], row["body"], row["ip_addr"], row["score"]
danbooru2_conn.exec "insert into comments (id, created_at, updated_at, post_id, creator_id, body, ip_addr, score, updater_id, updater_ip_addr) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", [row["id"], row["created_at"], row["created_at"], row["post_id"], row["user_id"], row["body"], row["ip_addr"], row["score"], row["user_id"], row["ip_addr"]]
danbooru2_conn.exec "insert into comments (id, created_at, updated_at, post_id, creator_id, body, ip_addr, score, updater_id, updater_ip_addr) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", [row["id"], row["created_at"], row["created_at"], row["post_id"], row["user_id"], row["body"], row["ip_addr"], row["score"], row["user_id"], row["ip_addr"]]
end
end
Regular → Executable
+1 -1
View File
@@ -22,7 +22,7 @@ Post.where("created_at >= '2013-02-01'").select("id, score, up_score, down_score
revised_score = post.up_score + post.down_score + fav_count
puts "#{post.id}: #{post.score} -> #{revised_score}" if post.score != revised_score
post.update_column(:score, revised_score)
end ; true
end; true
Post.where("is_deleted = true and created_at >= '2013-02-01'").find_each do |post|
if post.flags.empty?
Regular → Executable
View File
View File
Regular → Executable
+1 -1
View File
@@ -16,6 +16,6 @@ Post.where("id in (?)", Pool.find(203).post_id_array).find_each do |post|
FileUtils.mv(post.real_preview_file_path, post.real_preview_file_path.sub(post.md5, correct_md5))
FileUtils.mv(post.ssd_preview_file_path, post.ssd_preview_file_path.sub(post.md5, correct_md5))
end
FileUtils.mv(post.file_path, post.file_path.sub(post.md5, correct_md5))
end
Regular → Executable
View File
View File
View File
View File
View File
View File
+1 -1
View File
@@ -9,7 +9,7 @@ CurrentUser.ip_addr = "127.0.0.1"
CurrentUser.without_safe_mode do
sample_tags = %w(pixiv_manga_sample pixiv_thumbnail deviantart_thumbnail thumbnail nico_nico_thumbnail twitpic_thumbnail tumblr_sample imageboard_sample nijie_sample)
Post.tag_match(sample_tags.map{|tag| "~" + tag}.join(" ")).where("is_deleted = true and parent_id is not null and fav_count > 0").find_each do |post|
Post.tag_match(sample_tags.map {|tag| "~" + tag}.join(" ")).where("is_deleted = true and parent_id is not null and fav_count > 0").find_each do |post|
if (post.parent.tag_array & sample_tags).any?
next
else
+3 -3
View File
@@ -4,8 +4,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config',
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
0.upto(1585206 / 1000) do |i|
puts "updating posts #{i * 1000} to #{(i+1) * 1000}"
ActiveRecord::Base.connection.execute("update posts set last_commented_at = (select c.created_at from comments c where c.post_id = posts.id order by c.id desc limit 1) where posts.id between #{i * 1000} and #{(i+1) * 1000}")
puts "updating posts #{i * 1000} to #{(i + 1) * 1000}"
ActiveRecord::Base.connection.execute("update posts set last_commented_at = (select c.created_at from comments c where c.post_id = posts.id order by c.id desc limit 1) where posts.id between #{i * 1000} and #{(i + 1) * 1000}")
end
TagImplication.find_each do |ti|
@@ -13,7 +13,7 @@ TagImplication.find_each do |ti|
if ta
puts "testing alias #{ta.antecedent_name} -> #{ta.consequent_name}"
existing_ti = TagImplication.where("antecedent_name = ? AND consequent_name = ?", ta.consequent_name, ti.consequent_name).first
existing_ti.destroy if existing_ti
existing_ti&.destroy
if ta.consequent_name == ti.consequent_name
puts " deleting implication #{ti.antecedent_name} -> #{ti.consequent_name}"
View File
View File
View File
Regular → Executable
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
Regular → Executable
View File
+1 -1
View File
@@ -6,6 +6,6 @@ ArtistUrl.without_timeout do
ArtistUrl.where("normalized_url like ?", "\%nicovideo\%").find_each do |url|
before = url.normalized_url
url.normalize
puts "#{before} -> #{url.normalized_url}" if before != url.normalized_url unless ArtistUrl.where(normalized_url: url.normalized_url).exists?
puts "#{before} -> #{url.normalized_url}" unless ArtistUrl.where(normalized_url: url.normalized_url).exists? || before == url.normalized_url
end
end
+1 -1
View File
@@ -5,7 +5,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config',
CurrentUser.user = User.system
CurrentUser.ip_addr = "127.0.0.1"
ModAction.without_timeout do
ModAction.without_timeout do
ModAction.where(creator_id: 1).where("created_at > ? and description like ?", "2017-07-18", "permanently deleted post%").find_each do |ma|
post_id = ma.description.scan(/\d+/).first
puts "deleting favorites for #{post_id}"
Regular → Executable
+1 -1
View File
@@ -13,7 +13,7 @@ BAD_TITLES = ["My collection", "hi", "My private videos", "My video", "hey", "My
spammers = Set.new(Dmail.where("dmails.from_id >= ? and dmails.created_at >= ? and is_spam = ?", MIN_USER_ID, MIN_DATE, true).joins("join users on users.id = dmails.from_id").where("users.name ~ '^[a-z0-9]+[0-9]{3,}$'").pluck("users.id").map(&:to_i).uniq)
new_spammers = Set.new
User.without_timeout do
User.without_timeout do
Dmail.where("created_at >= ? and is_spam = ?", MIN_DATE, false).find_each do |dmail|
from_name = dmail.from_name
if dmail.from_id >= MIN_USER_ID && from_name =~ NAME_REGEXP
View File
+1 -1
View File
@@ -10,7 +10,7 @@ Tag.transaction do
total = empty_gentags.count
empty_gentags.find_each.with_index do |tag, i|
STDERR.puts %{validating "#{tag.name}" (#{i}/#{total})} if i % 1000 == 0
warn %{validating "#{tag.name}" (#{i}/#{total})} if i % 1000 == 0
if tag.invalid?(:create)
# puts ({ name: tag.name, id: tag.id }).to_json
View File
View File
View File
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby
require_relative "../../config/environment"
def fix_favorites
Favorite.without_timeout do
# delete favorites with a nonexistent post_id
Favorite.where("NOT EXISTS (SELECT 1 FROM posts WHERE posts.id = favorites.post_id)").delete_all
end
end
def fix_migrations
ApplicationRecord.connection.execute("DELETE FROM scheme_migrations WHERE version = '201704142336170'")
end