Merge branch 'new-upload-formula'

This commit is contained in:
r888888888
2015-09-11 15:46:44 -07:00
3 changed files with 34 additions and 24 deletions

View File

@@ -485,7 +485,7 @@ class User < ActiveRecord::Base
if created_at > 1.week.ago if created_at > 1.week.ago
"cannot upload during your first week of registration" "cannot upload during your first week of registration"
else else
"can not upload until your pending posts have been approved" "have reached your upload limit for the day"
end end
end end
@@ -513,22 +513,33 @@ class User < ActiveRecord::Base
created_at <= 1.week.ago created_at <= 1.week.ago
end end
def upload_limit def base_upload_limit
deleted_count = Post.for_user(id).deleted.where("is_banned = false").count if created_at >= 1.month.ago
pending_count = Post.for_user(id).pending.count 10
approved_count = Post.where("is_flagged = false and is_pending = false and is_deleted = false and uploader_id = ?", id).count elsif created_at >= 2.months.ago
20
if base_upload_limit.to_i != 0 elsif created_at >= 3.months.ago
limit = [base_upload_limit - (deleted_count / 4), 4].max - pending_count 30
elsif created_at >= 4.months.ago
40
else else
limit = [10 + (approved_count / 10) - (deleted_count / 4), 4].max - pending_count 50
end end
end
if limit < 0 def upload_limit
limit = 0 @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 end
limit
end end
def tag_query_limit def tag_query_limit
@@ -762,7 +773,7 @@ class User < ActiveRecord::Base
module StatisticsMethods module StatisticsMethods
def deletion_confidence(days = 30) def deletion_confidence(days = 30)
Reports::UserPromotion.deletion_confidence_interval_for(self, days) Reports::UserPromotions.deletion_confidence_interval_for(self, days)
end end
end end

View File

@@ -54,17 +54,12 @@ class UserPresenter
return "none" return "none"
end end
deleted_count = Post.for_user(user.id).deleted.where("is_banned = false").count dcon = [user.deletion_confidence(120), 15].min
pending_count = Post.for_user(user.id).pending.count multiplier = (1 - (dcon / 15.0))
approved_count = Post.where("is_flagged = false and is_pending = false and is_deleted = false and uploader_id = ?", user.id).count 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 "(#{user.base_upload_limit} * #{'%0.2f' % multiplier}) - #{uploaded_count} = #{user.upload_limit}"
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}"
end end
def uploads def uploads

View File

@@ -7,6 +7,10 @@
<p>Before uploading, please read the <%= link_to "how to upload guide", wiki_pages_path(:title => "howto:upload") %>.</p> <p>Before uploading, please read the <%= link_to "how to upload guide", wiki_pages_path(:title => "howto:upload") %>.</p>
</div> </div>
<% unless CurrentUser.is_contributor? %>
<p>You can upload <strong><%= pluralize CurrentUser.upload_limit, "more post" %></strong> today.</p>
<% end %>
<% if params[:url].blank? %> <% if params[:url].blank? %>
<div id="bookmarklet-notice"> <div id="bookmarklet-notice">
<p><span style="font-weight: bold;">You should be using Danbooru's official <%= link_to "upload bookmarklet", bookmarklet_path %> to upload!</span> It makes uploading more convenient and does several things for you automatically such as fixing incorrect sources and optionally copying the artist's commentary.</p> <p><span style="font-weight: bold;">You should be using Danbooru's official <%= link_to "upload bookmarklet", bookmarklet_path %> to upload!</span> It makes uploading more convenient and does several things for you automatically such as fixing incorrect sources and optionally copying the artist's commentary.</p>