From 1ef363dd6807f25a2ffb2c662825ed3cdc886b35 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 10 Aug 2017 23:52:47 -0500 Subject: [PATCH] upload limits: add time remaining until next upload to profiles (fix #3262). --- app/models/user.rb | 4 ++++ app/presenters/user_presenter.rb | 5 +++-- app/views/users/_statistics.html.erb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 57ac132fb..9f13de0e0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -585,6 +585,10 @@ class User < ApplicationRecord end end + def next_free_upload_slot + (posts.where("created_at >= ?", 24.hours.ago).first.try(:created_at) || 24.hours.ago) + 24.hours + end + def tag_query_limit if is_platinum? Danbooru.config.base_tag_query_limit * 2 diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index b5bea4e0a..2e01d0794 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -63,11 +63,12 @@ class UserPresenter end end - def upload_limit + def upload_limit(template) if user.can_upload_free? return "none" end + slots_tooltip = "Next free slot: #{template.time_ago_in_words(user.next_free_upload_slot)}" limit_tooltip = <<-EOS.strip_heredoc Base: #{user.base_upload_limit} Del. Rate: #{"%.2f" % user.adjusted_deletion_confidence} @@ -75,7 +76,7 @@ class UserPresenter Upload Limit: #{user.base_upload_limit} * #{"%.2f" % user.upload_limit_multiplier} = #{user.max_upload_limit} EOS - %{#{user.used_upload_slots} / #{user.upload_limit}}.html_safe + %{#{user.used_upload_slots} / #{user.max_upload_limit}}.html_safe end def uploads diff --git a/app/views/users/_statistics.html.erb b/app/views/users/_statistics.html.erb index c5deecb12..d70c0d181 100644 --- a/app/views/users/_statistics.html.erb +++ b/app/views/users/_statistics.html.erb @@ -31,7 +31,7 @@ Upload Limit - <%= presenter.upload_limit %> (<%= link_to "help", wiki_pages_path(title: "about:upload_limits") %>) + <%= presenter.upload_limit(self) %> (<%= link_to "help", wiki_pages_path(title: "about:upload_limits") %>)