BURs: remove old single alias/implication pruning code.
* Rename TagChangeRequestPruner to BulkUpdateRequestPruner. * Remove old code for pruning individual alias / implication requests.
This commit is contained in:
27
app/logical/bulk_update_request_pruner.rb
Normal file
27
app/logical/bulk_update_request_pruner.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
module BulkUpdateRequestPruner
|
||||
module_function
|
||||
|
||||
def warn_old
|
||||
BulkUpdateRequest.old.pending.find_each do |bulk_update_request|
|
||||
if bulk_update_request.forum_topic
|
||||
body = "This bulk update request is pending automatic rejection in 5 days."
|
||||
unless bulk_update_request.forum_topic.posts.where(creator_id: User.system.id, body: body).exists?
|
||||
bulk_update_request.forum_updater.update(body)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reject_expired
|
||||
BulkUpdateRequest.expired.pending.find_each do |bulk_update_request|
|
||||
ApplicationRecord.transaction do
|
||||
if bulk_update_request.forum_topic
|
||||
body = "This bulk update request has been rejected because it was not approved within 60 days."
|
||||
bulk_update_request.forum_updater.update(body)
|
||||
end
|
||||
|
||||
bulk_update_request.reject!(User.system)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -12,8 +12,8 @@ module DanbooruMaintenance
|
||||
safely { PostDisapproval.dmail_messages! }
|
||||
safely { regenerate_post_counts! }
|
||||
safely { TokenBucket.prune! }
|
||||
safely { TagChangeRequestPruner.warn_all }
|
||||
safely { TagChangeRequestPruner.reject_all }
|
||||
safely { BulkUpdateRequestPruner.warn_old }
|
||||
safely { BulkUpdateRequestPruner.reject_expired }
|
||||
safely { Ban.prune! }
|
||||
safely { ActiveRecord::Base.connection.execute("vacuum analyze") unless Rails.env.test? }
|
||||
end
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
# Service to prune old unapproved tag change requests
|
||||
# (including tag aliases, tag implications, and bulk
|
||||
# update requests).
|
||||
|
||||
class TagChangeRequestPruner
|
||||
def self.warn_all
|
||||
[TagAlias, TagImplication, BulkUpdateRequest].each do |model|
|
||||
new.warn_old(model)
|
||||
end
|
||||
end
|
||||
|
||||
def self.reject_all
|
||||
[TagAlias, TagImplication, BulkUpdateRequest].each do |model|
|
||||
new.reject_expired(model)
|
||||
end
|
||||
end
|
||||
|
||||
def warn_old(model)
|
||||
model.old.pending.find_each do |tag_change|
|
||||
if tag_change.forum_topic
|
||||
name = model.model_name.human.downcase
|
||||
body = "This #{name} is pending automatic rejection in 5 days."
|
||||
unless tag_change.forum_topic.posts.where(creator_id: User.system.id, body: body).exists?
|
||||
tag_change.forum_updater.update(body)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reject_expired(model)
|
||||
model.expired.pending.find_each do |tag_change|
|
||||
ApplicationRecord.transaction do
|
||||
if tag_change.forum_topic
|
||||
name = model.model_name.human.downcase
|
||||
body = "This #{name} has been rejected because it was not approved within 60 days."
|
||||
tag_change.forum_updater.update(body)
|
||||
end
|
||||
|
||||
CurrentUser.as_system do
|
||||
tag_change.reject!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -93,7 +93,7 @@ class BulkUpdateRequest < ApplicationRecord
|
||||
|
||||
def reject!(rejector = User.system)
|
||||
transaction do
|
||||
update(status: "rejected")
|
||||
update!(status: "rejected")
|
||||
forum_updater.update("The #{bulk_update_request_link} (forum ##{forum_post.id}) has been rejected by @#{rejector.name}.")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user