From 04ded35e7560736538818a661fcf63912ceeee2d Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 13 Aug 2015 15:18:27 -0700 Subject: [PATCH] updated formula for #2492 --- app/models/user.rb | 39 ++++++++++++++++++++------------ app/presenters/user_presenter.rb | 15 ++++-------- app/views/uploads/new.html.erb | 4 ++++ 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index caaf03313..a81f8efd3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -485,7 +485,7 @@ class User < ActiveRecord::Base if created_at > 1.week.ago "cannot upload during your first week of registration" else - "can not upload until your pending posts have been approved" + "have reached your upload limit for the day" end end @@ -513,22 +513,33 @@ class User < ActiveRecord::Base created_at <= 1.week.ago end - def upload_limit - deleted_count = Post.for_user(id).deleted.where("is_banned = false").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 - - if base_upload_limit.to_i != 0 - limit = [base_upload_limit - (deleted_count / 4), 4].max - pending_count + def base_upload_limit + if created_at >= 1.month.ago + 10 + elsif created_at >= 2.months.ago + 20 + elsif created_at >= 3.months.ago + 30 + elsif created_at >= 4.months.ago + 40 else - limit = [10 + (approved_count / 10) - (deleted_count / 4), 4].max - pending_count + 50 end + end - if limit < 0 - limit = 0 + def upload_limit + @upload_limit ||= begin + dcon = [deletion_confidence(120), 15].min + max_count = [(base_upload_limit * (1 - (dcon / 15.0))).ceil, 10].max + uploaded_count = Post.for_user(id).where("created_at >= ?", 24.hours.ago).count + limit = max_count - uploaded_count + + if limit < 0 + limit = 0 + end + + limit end - - limit end def tag_query_limit @@ -762,7 +773,7 @@ class User < ActiveRecord::Base module StatisticsMethods def deletion_confidence(days = 30) - Reports::UserPromotion.deletion_confidence_interval_for(self, days) + Reports::UserPromotions.deletion_confidence_interval_for(self, days) end end diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 62e1cd517..42a56d854 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -54,17 +54,12 @@ class UserPresenter return "none" end - deleted_count = Post.for_user(user.id).deleted.where("is_banned = false").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 + dcon = [user.deletion_confidence(120), 15].min + multiplier = (1 - (dcon / 15.0)) + max_count = [(user.base_upload_limit * multiplier).ceil, 5].max + uploaded_count = Post.for_user(user.id).where("created_at >= ?", 24.hours.ago).count - if user.base_upload_limit.to_i != 0 - string = "max(base:#{user.base_upload_limit} - (deleted:#{deleted_count} / 4), 4) - pending:#{pending_count}" - else - string = "max(10 + (approved:#{approved_count} / 10) - (deleted:#{deleted_count} / 4), 4) - pending:#{pending_count}" - end - - "#{string} = #{user.upload_limit}" + "(#{user.base_upload_limit} * #{'%0.2f' % multiplier}) - #{uploaded_count} = #{user.upload_limit}" end def uploads diff --git a/app/views/uploads/new.html.erb b/app/views/uploads/new.html.erb index 00531bf03..3bd6a3866 100644 --- a/app/views/uploads/new.html.erb +++ b/app/views/uploads/new.html.erb @@ -7,6 +7,10 @@

Before uploading, please read the <%= link_to "how to upload guide", wiki_pages_path(:title => "howto:upload") %>.

+ <% unless CurrentUser.is_contributor? %> +

You can upload <%= pluralize CurrentUser.upload_limit, "more post" %> today.

+ <% end %> + <% if params[:url].blank? %>

You should be using Danbooru's official <%= link_to "upload bookmarklet", bookmarklet_path %> to upload! It makes uploading more convenient and does several things for you automatically such as fixing incorrect sources and optionally copying the artist's commentary.