rubocop: fix various style issues.
This commit is contained in:
0
script/fixes/004.rb
Normal file → Executable file
0
script/fixes/004.rb
Normal file → Executable file
4
script/fixes/005.rb
Normal file → Executable file
4
script/fixes/005.rb
Normal file → Executable 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
|
||||
|
||||
0
script/fixes/006.rb
Normal file → Executable file
0
script/fixes/006.rb
Normal file → Executable file
0
script/fixes/007.rb
Normal file → Executable file
0
script/fixes/007.rb
Normal file → Executable file
0
script/fixes/008.rb
Normal file → Executable file
0
script/fixes/008.rb
Normal file → Executable file
0
script/fixes/009.rb
Normal file → Executable file
0
script/fixes/009.rb
Normal file → Executable file
0
script/fixes/010.rb
Normal file → Executable file
0
script/fixes/010.rb
Normal file → Executable file
0
script/fixes/011.rb
Normal file → Executable file
0
script/fixes/011.rb
Normal file → Executable file
0
script/fixes/012.rb
Normal file → Executable file
0
script/fixes/012.rb
Normal file → Executable file
10
script/fixes/013.rb
Normal file → Executable file
10
script/fixes/013.rb
Normal file → Executable 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
|
||||
|
||||
2
script/fixes/014_note_ranges.rb
Normal file → Executable file
2
script/fixes/014_note_ranges.rb
Normal file → Executable 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?
|
||||
|
||||
0
script/fixes/015.rb
Normal file → Executable file
0
script/fixes/015.rb
Normal file → Executable file
0
script/fixes/016_fix_swf_dimensions.rb
Normal file → Executable file
0
script/fixes/016_fix_swf_dimensions.rb
Normal file → Executable file
2
script/fixes/017_fix_md5.rb
Normal file → Executable file
2
script/fixes/017_fix_md5.rb
Normal file → Executable 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
|
||||
|
||||
0
script/fixes/018_fix_md5.rb
Normal file → Executable file
0
script/fixes/018_fix_md5.rb
Normal file → Executable file
0
script/fixes/019_fix_pool_names.rb
Normal file → Executable file
0
script/fixes/019_fix_pool_names.rb
Normal file → Executable file
0
script/fixes/020_retrieve_bad_md5_posts.rb
Normal file → Executable file
0
script/fixes/020_retrieve_bad_md5_posts.rb
Normal file → Executable file
0
script/fixes/021_fix_deleted_pool_strings.rb
Normal file → Executable file
0
script/fixes/021_fix_deleted_pool_strings.rb
Normal file → Executable file
0
script/fixes/022_expunge_missing_images.rb
Normal file → Executable file
0
script/fixes/022_expunge_missing_images.rb
Normal file → Executable file
0
script/fixes/023_remove_expunged_posts_from_pools.rb
Normal file → Executable file
0
script/fixes/023_remove_expunged_posts_from_pools.rb
Normal file → Executable file
2
script/fixes/024_move_favorites_to_parent.rb
Normal file → Executable file
2
script/fixes/024_move_favorites_to_parent.rb
Normal file → Executable 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
|
||||
|
||||
6
script/fixes/025_last_commented_at.rb
Normal file → Executable file
6
script/fixes/025_last_commented_at.rb
Normal file → Executable 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}"
|
||||
|
||||
0
script/fixes/026_fix_unicode_capitals.rb
Normal file → Executable file
0
script/fixes/026_fix_unicode_capitals.rb
Normal file → Executable file
0
script/fixes/027_fix_banned_artists.rb
Normal file → Executable file
0
script/fixes/027_fix_banned_artists.rb
Normal file → Executable file
0
script/fixes/028_fix_has_children.rb
Normal file → Executable file
0
script/fixes/028_fix_has_children.rb
Normal file → Executable file
0
script/fixes/029_iqdb_import.rb
Normal file → Executable file
0
script/fixes/029_iqdb_import.rb
Normal file → Executable file
0
script/fixes/030_calculate_has_active_children.rb
Normal file → Executable file
0
script/fixes/030_calculate_has_active_children.rb
Normal file → Executable file
0
script/fixes/031_fix_ugoira_dimensions.rb
Normal file → Executable file
0
script/fixes/031_fix_ugoira_dimensions.rb
Normal file → Executable file
0
script/fixes/032_add_pool_category_pseudo_tags.rb
Normal file → Executable file
0
script/fixes/032_add_pool_category_pseudo_tags.rb
Normal file → Executable file
0
script/fixes/033_enable_can_approve_posts_flag.rb
Normal file → Executable file
0
script/fixes/033_enable_can_approve_posts_flag.rb
Normal file → Executable file
0
script/fixes/034_fix_dmail_filters.rb
Normal file → Executable file
0
script/fixes/034_fix_dmail_filters.rb
Normal file → Executable file
0
script/fixes/035_fix_nico_seiga_artist_urls.rb
Normal file → Executable file
0
script/fixes/035_fix_nico_seiga_artist_urls.rb
Normal file → Executable file
0
script/fixes/036_fix_hentai_foundry_artist_urls.rb
Normal file → Executable file
0
script/fixes/036_fix_hentai_foundry_artist_urls.rb
Normal file → Executable file
0
script/fixes/037_enable_can_upload_free.rb
Normal file → Executable file
0
script/fixes/037_enable_can_upload_free.rb
Normal file → Executable file
0
script/fixes/038_reset_categorized_saved_search_setting.rb
Normal file → Executable file
0
script/fixes/038_reset_categorized_saved_search_setting.rb
Normal file → Executable file
0
script/fixes/039_fix_saved_search_categories.rb
Normal file → Executable file
0
script/fixes/039_fix_saved_search_categories.rb
Normal file → Executable file
0
script/fixes/040_fix_post_scores.rb
Normal file → Executable file
0
script/fixes/040_fix_post_scores.rb
Normal file → Executable file
0
script/fixes/041_remove_expunged_posts_from_iqdb.rb
Normal file → Executable file
0
script/fixes/041_remove_expunged_posts_from_iqdb.rb
Normal file → Executable file
0
script/fixes/042_fix_user_cache_counters.rb
Normal file → Executable file
0
script/fixes/042_fix_user_cache_counters.rb
Normal file → Executable file
0
script/fixes/043_fix_whitespace_usernames.rb
Normal file → Executable file
0
script/fixes/043_fix_whitespace_usernames.rb
Normal file → Executable file
0
script/fixes/044_initialized_saved_search_tags.rb
Normal file → Executable file
0
script/fixes/044_initialized_saved_search_tags.rb
Normal file → Executable file
0
script/fixes/045_dedup_users.rb
Normal file → Executable file
0
script/fixes/045_dedup_users.rb
Normal file → Executable file
2
script/fixes/046_fix_nicovideo_artist_urls.rb
Normal file → Executable file
2
script/fixes/046_fix_nicovideo_artist_urls.rb
Normal file → Executable 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
|
||||
|
||||
2
script/fixes/048_remove_expunged_favorites.rb
Normal file → Executable file
2
script/fixes/048_remove_expunged_favorites.rb
Normal file → Executable 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}"
|
||||
|
||||
2
script/fixes/049_spam_1.rb
Normal file → Executable file
2
script/fixes/049_spam_1.rb
Normal file → Executable 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
|
||||
|
||||
0
script/fixes/050_fix_post_tagcount.rb
Normal file → Executable file
0
script/fixes/050_fix_post_tagcount.rb
Normal file → Executable 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
|
||||
|
||||
0
script/fixes/053_normalize_ugoira_data.rb
Normal file → Executable file
0
script/fixes/053_normalize_ugoira_data.rb
Normal file → Executable file
0
script/fixes/055_reindex_replacements_in_iqdb.rb
Normal file → Executable file
0
script/fixes/055_reindex_replacements_in_iqdb.rb
Normal file → Executable file
0
script/fixes/056_message_nonascii_usernames.rb
Normal file → Executable file
0
script/fixes/056_message_nonascii_usernames.rb
Normal file → Executable file
14
script/fixes/059_fix_favorites.rb
Executable file
14
script/fixes/059_fix_favorites.rb
Executable 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
|
||||
@@ -5,7 +5,7 @@ require_relative './mock_service_helper'
|
||||
set :port, 3002
|
||||
|
||||
configure do
|
||||
POST_IDS = MockServiceHelper.fetch_post_ids()
|
||||
POST_IDS = MockServiceHelper.fetch_post_ids
|
||||
end
|
||||
|
||||
get '/similar' do
|
||||
|
||||
@@ -3,11 +3,11 @@ require 'timeout'
|
||||
require 'httparty'
|
||||
|
||||
module MockServiceHelper
|
||||
extend self
|
||||
module_function
|
||||
|
||||
DANBOORU_PORT = 3000
|
||||
|
||||
def fetch_post_ids()
|
||||
def fetch_post_ids
|
||||
begin
|
||||
s = TCPSocket.new("localhost", DANBOORU_PORT)
|
||||
s.close
|
||||
|
||||
@@ -5,7 +5,7 @@ require_relative './mock_service_helper'
|
||||
set :port, 3001
|
||||
|
||||
configure do
|
||||
POST_IDS = MockServiceHelper.fetch_post_ids()
|
||||
POST_IDS = MockServiceHelper.fetch_post_ids
|
||||
end
|
||||
|
||||
get '/recommend/:user_id' do
|
||||
@@ -15,5 +15,5 @@ end
|
||||
|
||||
get '/similar/:post_id' do
|
||||
content_type :json
|
||||
POST_IDS[0..6].map {|x| [x, "1.000"]}.to_json
|
||||
POST_IDS[0..6].map {|x| [x, "1.000"]}.to_json
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user