diff --git a/app/models/user.rb b/app/models/user.rb index 52ac19255..1440dac14 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -433,14 +433,14 @@ class User < ActiveRecord::Base end def upload_limit - deleted_count = Post.for_user(id).deleted.count - pending_count = Post.for_user(id).pending.count - approved_count = Post.where("is_flagged = false and is_pending = false and is_deleted = false and uploader_id = ?", id).count + 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 - limit = base_upload_limit - pending_count + limit = base_upload_limit - (deleted_count / 5) - pending_count else - limit = 10 + (approved_count / 10) - (deleted_count / 4) - pending_count + limit = 10 + (approved_count / 10) - (deleted_count / 5) - pending_count end if limit < 0 diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index ca9e1a7be..666e5dff2 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -37,27 +37,8 @@ class UserPresenter if user.is_contributor? return "none" end - - deleted_count = Post.for_user(user.id).deleted.count - 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 + + return user.upload_limit.to_s end def uploads