docs: add documentation for various classes in app/logical.

This commit is contained in:
evazion
2021-06-23 05:09:55 -05:00
parent e5cfb7904c
commit ed302fdf4d
33 changed files with 518 additions and 25 deletions

View File

@@ -1,9 +1,17 @@
# Demote all approvers who haven't approved at least 30 posts in the last 45
# days. Moderators and recently promoted approvers are exempt. Runs as a monthly
# maintenance task. Approvers who are facing demotion are sent a weekly warning
# dmail first.
#
# @see DanbooruMaintenance#monthly
module ApproverPruner
module_function
APPROVAL_PERIOD = 45.days
MINIMUM_APPROVALS = 30
# Get the list of inactive approvers.
# @return [Array<User>] the list of inactive approvers
def inactive_approvers
approvers = User.bit_prefs_match(:can_approve_posts, true)
approvers = approvers.where("level < ?", User::Levels::MODERATOR)
@@ -16,9 +24,10 @@ module ApproverPruner
end
end
# Demote all inactive approvers
def prune!
inactive_approvers.each do |user|
CurrentUser.scoped(User.system, "127.0.0.1") do
CurrentUser.scoped(User.system) do
user.update!(can_approve_posts: false)
user.feedback.create(category: "neutral", body: "Lost approval privileges", creator: User.system)
@@ -31,6 +40,7 @@ module ApproverPruner
end
end
# Send a warning dmail to approvers who are pending demotion.
def dmail_inactive_approvers!
days_until_next_month = (Date.current.next_month.beginning_of_month - Date.current).to_i
return unless days_until_next_month <= 21