changes to fix
This commit is contained in:
@@ -5,7 +5,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config',
|
|||||||
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||||
|
|
||||||
Comment.find_each do |comment|
|
Comment.find_each do |comment|
|
||||||
if !Post.exists?("id = #{comment.post_id}")
|
if !Post.exists?(comment.post_id)
|
||||||
puts "deleting comment #{comment.id}"
|
puts "deleting comment #{comment.id}"
|
||||||
comment.destroy
|
comment.destroy
|
||||||
end
|
end
|
||||||
@@ -18,16 +18,9 @@ end ; true
|
|||||||
|
|
||||||
ArtistVersion.update_all "is_banned = false"
|
ArtistVersion.update_all "is_banned = false"
|
||||||
|
|
||||||
Artist.find_each do |artist|
|
Artist.where("is_banned = true").find_each do |artist|
|
||||||
if artist.is_banned?
|
puts "updating artist #{artist.id}"
|
||||||
puts "updating artist #{artist.id}"
|
artist.versions.last.update_column(:is_banned, true)
|
||||||
artist.versions.last.update_column(:is_banned, true)
|
|
||||||
end
|
|
||||||
end ; true
|
|
||||||
|
|
||||||
Post.find_each do |post|
|
|
||||||
puts "updating post #{post.id}"
|
|
||||||
post.update_column(:fav_count, Favorite.where("post_id = #{post.id}").count)
|
|
||||||
end ; true
|
end ; true
|
||||||
|
|
||||||
User.find_each do |user|
|
User.find_each do |user|
|
||||||
@@ -35,6 +28,21 @@ User.find_each do |user|
|
|||||||
user.update_column(:favorite_count, Favorite.for_user(user).where("user_id = ?", user.id).count)
|
user.update_column(:favorite_count, Favorite.for_user(user).where("user_id = ?", user.id).count)
|
||||||
end ; true
|
end ; true
|
||||||
|
|
||||||
|
Post.find_each do |post|
|
||||||
|
puts "updating post #{post.id}"
|
||||||
|
post.update_column(:fav_count, Favorite.where("post_id = #{post.id}").count)
|
||||||
|
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|
|
||||||
|
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"]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Post.select("id, score, up_score, down_score, fav_count").find_each do |post|
|
# Post.select("id, score, up_score, down_score, fav_count").find_each do |post|
|
||||||
# post.update_column(:score, post.up_score + post.down_score)
|
# post.update_column(:score, post.up_score + post.down_score)
|
||||||
|
|||||||
Reference in New Issue
Block a user