fixes #2517: Janitor trial report broken

This commit is contained in:
r888888888
2015-09-17 11:35:50 -07:00
parent 6297ff8638
commit 486cdcb039
5 changed files with 27 additions and 14 deletions

View File

@@ -11,6 +11,10 @@ module Reports
JanitorTrial.where(user_id: user.id).first
end
def created_at
trial.created_at
end
def since
3.months.ago
end

View File

@@ -18,6 +18,10 @@ module Reports
Reports::UserPromotions.deletion_confidence_interval_for(user)
end
def negative_score_confidence_interval
Reports::UserPromotions.negative_score_confidence_interval_for(user)
end
def median_score
ActiveRecord::Base.select_value_sql("select percentile_cont(0.50) within group (order by score) from posts where created_at >= ? and uploader_id = ?", ::Reports::UserPromotions.min_time, user.id).to_i
end
@@ -40,6 +44,13 @@ module Reports
ci_lower_bound(deletions, total)
end
def self.negative_score_confidence_interval_for(user, days = nil)
date = (days || 30).days.ago
hits = Post.where("created_at >= ? and score < 0", date).where(:uploader_id => user.id).count
total = Post.where("created_at >= ?", date).where(:uploader_id => user.id).count
ci_lower_bound(hits, total)
end
def self.ci_lower_bound(pos, n, confidence = 0.95)
if n == 0
return 0