upload limits: refactor deletion confidence calculation.
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
module Reports
|
|
||||||
class UserPromotions
|
|
||||||
def self.deletion_confidence_interval_for(user, days = nil)
|
|
||||||
date = (days || 60).days.ago
|
|
||||||
deletions = Post.where("created_at >= ?", date).where(:uploader_id => user.id, :is_deleted => true).count
|
|
||||||
total = Post.where("created_at >= ?", date).where(:uploader_id => user.id).count
|
|
||||||
DanbooruMath.ci_lower_bound(deletions, total)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -479,10 +479,16 @@ class User < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def adjusted_deletion_confidence
|
def adjusted_deletion_confidence
|
||||||
[deletion_confidence(60), 15].min
|
[deletion_confidence(60.days.ago), 15].min
|
||||||
end
|
end
|
||||||
memoize :adjusted_deletion_confidence
|
memoize :adjusted_deletion_confidence
|
||||||
|
|
||||||
|
def deletion_confidence(date)
|
||||||
|
deletions = posts.deleted.where("created_at >= ?", date).count
|
||||||
|
total = posts.where("created_at >= ?", date).count
|
||||||
|
DanbooruMath.ci_lower_bound(deletions, total)
|
||||||
|
end
|
||||||
|
|
||||||
def base_upload_limit
|
def base_upload_limit
|
||||||
if created_at >= 1.month.ago
|
if created_at >= 1.month.ago
|
||||||
10
|
10
|
||||||
@@ -774,12 +780,6 @@ class User < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module StatisticsMethods
|
|
||||||
def deletion_confidence(days = 30)
|
|
||||||
Reports::UserPromotions.deletion_confidence_interval_for(self, days)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
concerning :SockPuppetMethods do
|
concerning :SockPuppetMethods do
|
||||||
def validate_sock_puppets
|
def validate_sock_puppets
|
||||||
if User.where(last_ip_addr: CurrentUser.ip_addr).where("created_at > ?", 1.day.ago).exists?
|
if User.where(last_ip_addr: CurrentUser.ip_addr).where("created_at > ?", 1.day.ago).exists?
|
||||||
@@ -799,7 +799,6 @@ class User < ApplicationRecord
|
|||||||
include ApiMethods
|
include ApiMethods
|
||||||
include CountMethods
|
include CountMethods
|
||||||
extend SearchMethods
|
extend SearchMethods
|
||||||
include StatisticsMethods
|
|
||||||
|
|
||||||
def as_current(&block)
|
def as_current(&block)
|
||||||
CurrentUser.as(self, &block)
|
CurrentUser.as(self, &block)
|
||||||
|
|||||||
Reference in New Issue
Block a user