BURs: reduce autorejection timeout from 60 days to 45 days.
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
# Rejects bulk update requests that haven't been approved in 60 days.
|
||||
# Rejects bulk update requests that haven't been approved in 45 days.
|
||||
module BulkUpdateRequestPruner
|
||||
module_function
|
||||
|
||||
# How many days before a bulk update request should be automatically rejected.
|
||||
EXPIRATION_PERIOD = 45.days
|
||||
|
||||
# How many days before we should warn about upcoming rejections.
|
||||
WARNING_PERIOD = 5.days
|
||||
|
||||
# Posts a warning when a bulk update request is pending automatic rejection in 5 days.
|
||||
def warn_old
|
||||
BulkUpdateRequest.old.pending.find_each do |bulk_update_request|
|
||||
upcoming_expired_requests.find_each do |bulk_update_request|
|
||||
if bulk_update_request.forum_topic
|
||||
body = "This bulk update request is pending automatic rejection in 5 days."
|
||||
body = "This bulk update request is pending automatic rejection in #{WARNING_PERIOD.inspect}."
|
||||
unless bulk_update_request.forum_topic.forum_posts.where(creator_id: User.system.id, body: body).exists?
|
||||
bulk_update_request.forum_updater.update(body)
|
||||
end
|
||||
@@ -14,12 +20,12 @@ module BulkUpdateRequestPruner
|
||||
end
|
||||
end
|
||||
|
||||
# Rejects bulk update requests that haven't been approved in 60 days.
|
||||
# Rejects bulk update requests that haven't been approved in 45 days.
|
||||
def reject_expired
|
||||
BulkUpdateRequest.expired.pending.find_each do |bulk_update_request|
|
||||
expired_requests.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."
|
||||
body = "This bulk update request has been rejected because it was not approved within #{EXPIRATION_PERIOD.inspect}."
|
||||
bulk_update_request.forum_updater.update(body)
|
||||
end
|
||||
|
||||
@@ -27,4 +33,12 @@ module BulkUpdateRequestPruner
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def expired_requests
|
||||
BulkUpdateRequest.pending.where("created_at < ?", EXPIRATION_PERIOD.ago)
|
||||
end
|
||||
|
||||
def upcoming_expired_requests
|
||||
BulkUpdateRequest.pending.where("created_at >= ? and created_at < ?", EXPIRATION_PERIOD.ago, (EXPIRATION_PERIOD - WARNING_PERIOD).ago)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user