tweak upload limit

This commit is contained in:
albert
2013-03-22 23:12:40 -04:00
parent b54759b74b
commit df54434456
3 changed files with 6 additions and 20 deletions

View File

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