This commit is contained in:
r888888888
2014-07-22 15:43:20 -07:00
parent 697836826a
commit 44b59ab18d
2 changed files with 23 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ class DailyMaintenance
Delayed::Job.delete_all(['created_at < ?', 7.days.ago])
PostVote.delete_all(['created_at < ?', 1.month.ago])
CommentVote.delete_all(['created_at < ?', 1.month.ago])
UserUploadClamper.new.clamp_all!
TagSubscription.process_all
ApiCacheGenerator.new.generate_tag_cache
end

View File

@@ -0,0 +1,22 @@
class UserUploadClamper
def clamp_all!
users.each do |user|
if clamp_user?(user)
clamp_user!(user)
end
end
end
def users
User.where("post_upload_count >= 200 and (base_upload_limit > 10 or base_upload_limit is null) and level < ?", User::Levels::CONTRIBUTOR).limit(50)
end
def clamp_user?(user)
Reports::UserPromotions.deletion_confidence_interval_for(user) >= 25
end
def clamp_user!(user)
user.update_attribute(:base_upload_limit, -1)
ModAction.create(:description => "user ##{user.id} (#{user.name}) clamped")
end
end