implement new user limiting
This commit is contained in:
@@ -438,9 +438,9 @@ class User < ActiveRecord::Base
|
||||
approved_count = Post.where("is_flagged = false and is_pending = false and is_deleted = false and uploader_id = ? and created_at >= ?", id, 1.month.ago).count
|
||||
|
||||
if base_upload_limit
|
||||
limit = base_upload_limit - (deleted_count / 5) - pending_count
|
||||
limit = [base_upload_limit - (deleted_count / 2), 4].max - pending_count
|
||||
else
|
||||
limit = 10 + (approved_count / 10) - (deleted_count / 5) - pending_count
|
||||
limit = [10 + [approved_count / 2, 20].min - (deleted_count / 2), 4].max - pending_count
|
||||
end
|
||||
|
||||
if limit < 0
|
||||
|
||||
@@ -38,7 +38,17 @@ class UserPresenter
|
||||
return "none"
|
||||
end
|
||||
|
||||
return user.upload_limit.to_s
|
||||
deleted_count = Post.for_user(id).deleted.where("created_at >= ?", 1.month.ago).count
|
||||
pending_count = Post.for_user(id).pending.where("created_at >= ?", 3.days.ago).count
|
||||
approved_count = Post.where("is_flagged = false and is_pending = false and is_deleted = false and uploader_id = ? and created_at >= ?", id, 1.month.ago).count
|
||||
|
||||
if base_upload_limit
|
||||
string = "max(base_upload_limit:#{base_upload_limit} - (deleted_count:#{deleted_count} / 2), 4) - pending_count:#{pending_count}"
|
||||
else
|
||||
string = "max(10 + min(approved_count:#{approved_count} / 2, 20) - (deleted_count:#{deleted_count} / 2), 4) - pending_count:#{pending_count}"
|
||||
end
|
||||
|
||||
"#{string} = #{user.upload_limit} (deletions and approvals within past month)"
|
||||
end
|
||||
|
||||
def uploads
|
||||
|
||||
Reference in New Issue
Block a user