add inactive approver pruner

This commit is contained in:
Albert Yi
2018-08-28 15:02:03 -07:00
parent 452413a80e
commit 31df8d9f87
2 changed files with 6 additions and 3 deletions

View File

@@ -1,8 +1,10 @@
class ApproverPruner
module ApproverPruner
extend self
def inactive_approvers
User.where("bit_prefs & ? > 0", User.flag_value_for("can_approve_posts")).select do |user|
approval_count = Post.where("created_at >= ? and approver_id = ?", 3.months.ago, user.id).count
approval_count == 0
approval_count < 10
end
end
@@ -23,7 +25,7 @@ class ApproverPruner
Dmail.create_automated(
:to_id => user.id,
:title => "Approver inactivity",
:body => "You haven't approved a post in the past three months. In order to make sure the list of active approvers is up-to-date, you have lost your approver privileges."
:body => "You've approved fewer than 10 posts in the past three months. In order to make sure the list of active approvers is up-to-date, you have lost your approval privileges. If you wish to dispute this, you can message an admin to have your permission reinstated."
)
end
end

View File

@@ -2,6 +2,7 @@ class WeeklyMaintenance
def run
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
UserPasswordResetNonce.prune!
ApproverPruner.prune!
# JanitorPruner.new.prune!
end
end