Merge branch 'post-archive'

This commit is contained in:
r888888888
2017-02-27 10:45:13 -08:00
20 changed files with 392 additions and 100 deletions

View File

@@ -27,7 +27,7 @@ class BulkRevert
end
def find_post_versions
q = PostVersion.where("true")
q = PostArchive.where("true")
if constraints[:user_name]
constraints[:user_id] = User.find_by_name(constraints[:user_name]).try(:id)

View File

@@ -34,7 +34,7 @@ module Moderator
add_row(sums, Hash[User.where(last_ip_addr: ip_addrs).collect { |user| [user, 1] }])
add_row_id(sums, PoolArchive.where(updater_ip_addr: ip_addrs).group(:updater_id).count) if PoolArchive.enabled?
add_row_id(sums, PostVersion.where(updater_ip_addr: ip_addrs).group(:updater_id).count)
add_row_id(sums, PostArchive.where(updater_ip_addr: ip_addrs).group(:updater_id).count) if PostArchive.enabled?
sums
end
@@ -52,7 +52,7 @@ module Moderator
add_row(sums, ArtistVersion.where(updater: users).group(:updater_ip_addr).count)
add_row(sums, NoteVersion.where(updater: users).group(:updater_ip_addr).count)
add_row(sums, PoolArchive.where(updater_id: users.map(&:id)).group(:updater_ip_addr).count) if PoolArchive.enabled?
add_row(sums, PostVersion.where(updater_id: users.map(&:id)).group(:updater_ip_addr).count)
add_row(sums, PostArchive.where(updater_id: users.map(&:id)).group(:updater_ip_addr).count) if PostArchive.enabled?
add_row(sums, WikiPageVersion.where(updater: users).group(:updater_ip_addr).count)
add_row(sums, Comment.where(creator: users).group(:ip_addr).count)
add_row(sums, Dmail.where(from: users).group(:creator_ip_addr).count)

View File

@@ -13,7 +13,7 @@ module Reports
end
def mock_version(row)
PostVersion.new.tap do |x|
PostArchive.new.tap do |x|
x.id = row["f"][0]["v"]
x.post_id = row["f"][1]["v"]
x.updated_at = Time.at(row["f"][2]["v"].to_f)

View File

@@ -15,13 +15,13 @@ class UserRevert
end
def validate!
if PostVersion.where(updater_id: user_id).count > THRESHOLD
if PostArchive.where(updater_id: user_id).count > THRESHOLD
raise TooManyChangesError.new("This user has too many changes to be reverted")
end
end
def revert_post_changes
PostVersion.where(updater_id: user_id).find_each do |x|
PostArchive.where(updater_id: user_id).find_each do |x|
x.undo!
end
end