add additional constraints on upload limit
This commit is contained in:
@@ -433,14 +433,14 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def upload_limit
|
def upload_limit
|
||||||
deleted_count = Post.for_user(id).deleted.count
|
deleted_count = Post.for_user(id).deleted.where("created_at >= ?", 1.month.ago).count
|
||||||
pending_count = Post.for_user(id).pending.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 = ?", id).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
|
if base_upload_limit
|
||||||
limit = base_upload_limit - pending_count
|
limit = base_upload_limit - (deleted_count / 5) - pending_count
|
||||||
else
|
else
|
||||||
limit = 10 + (approved_count / 10) - (deleted_count / 4) - pending_count
|
limit = 10 + (approved_count / 10) - (deleted_count / 5) - pending_count
|
||||||
end
|
end
|
||||||
|
|
||||||
if limit < 0
|
if limit < 0
|
||||||
|
|||||||
@@ -38,26 +38,7 @@ class UserPresenter
|
|||||||
return "none"
|
return "none"
|
||||||
end
|
end
|
||||||
|
|
||||||
deleted_count = Post.for_user(user.id).deleted.count
|
return user.upload_limit.to_s
|
||||||
pending_count = Post.for_user(user.id).pending.count
|
|
||||||
approved_count = Post.where("is_flagged = false and is_pending = false and is_deleted = false and uploader_id = ?", user.id).count
|
|
||||||
|
|
||||||
if user.base_upload_limit
|
|
||||||
limit = user.base_upload_limit - pending_count
|
|
||||||
string = "base:#{user.base_upload_limit} - pending:#{pending_count}"
|
|
||||||
else
|
|
||||||
limit = 10 + (approved_count / 10) - (deleted_count / 4) - pending_count
|
|
||||||
string = "base:10 + approved:(#{approved_count} / 10) - deleted:(#{deleted_count}) / 4 - pending:#{pending_count}"
|
|
||||||
end
|
|
||||||
|
|
||||||
if limit < 0
|
|
||||||
limit = 0
|
|
||||||
string += " = 0"
|
|
||||||
else
|
|
||||||
string += " = #{limit}"
|
|
||||||
end
|
|
||||||
|
|
||||||
return string
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def uploads
|
def uploads
|
||||||
|
|||||||
Reference in New Issue
Block a user