tweak upload limit numbers, fixes #1044

This commit is contained in:
albert
2013-03-22 21:25:16 -04:00
parent ee1a70033c
commit 733713ea67
2 changed files with 7 additions and 7 deletions

View File

@@ -433,14 +433,14 @@ class User < ActiveRecord::Base
end
def upload_limit
deleted_count = Post.for_user(id).deleted.where("created_at >= ?", 1.month.ago).count
deleted_count = Post.for_user(id).deleted.where("created_at >= ?", 3.months.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
approved_count = Post.where("is_flagged = false and is_pending = false and is_deleted = false and uploader_id = ? and created_at >= ?", id, 1.year.ago).count
if base_upload_limit
limit = [base_upload_limit - (deleted_count / 2), 4].max - pending_count
else
limit = [10 + [approved_count / 2, 30].min - (deleted_count / 2), 4].max - pending_count
limit = [10 + [approved_count / 2, 90].min - (deleted_count / 2), 4].max - pending_count
end
if limit < 0

View File

@@ -38,14 +38,14 @@ class UserPresenter
return "none"
end
deleted_count = Post.for_user(user.id).deleted.where("created_at >= ?", 1.month.ago).count
pending_count = Post.for_user(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 >= ?", user.id, 1.month.ago).count
deleted_count = Post.for_user(id).deleted.where("created_at >= ?", 3.months.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.year.ago).count
if user.base_upload_limit
string = "max(base_upload_limit:#{user.base_upload_limit} - (deleted_count:#{deleted_count} / 2), 4) - pending_count:#{pending_count}"
else
string = "max(10 + min(approved_count:#{approved_count} / 2, 30) - (deleted_count:#{deleted_count} / 2), 4) - pending_count:#{pending_count}"
string = "max(10 + min(approved_count:#{approved_count} / 2, 90) - (deleted_count:#{deleted_count} / 2), 4) - pending_count:#{pending_count}"
end
"#{string} = #{user.upload_limit} (deletions and approvals within past month)"