fixes #2480: Report for contributors

This commit is contained in:
r888888888
2015-08-07 17:23:11 -07:00
parent 10b2523ac3
commit e37775afc2
8 changed files with 82 additions and 9 deletions

View File

@@ -0,0 +1,9 @@
require 'statistics2'
module Reports
class Contributors < User
def users
::User.where("users.level >= ? and users.post_upload_count >= 250", ::User::Levels::CONTRIBUTOR).order("created_at desc").limit(50).map {|x| Reports::UserPromotions::User.new(x)}
end
end
end

View File

@@ -30,16 +30,17 @@ module Reports
def self.confidence_interval_for(user, n)
up_votes = Post.where("created_at >= ?", min_time).where(:is_deleted => false, :uploader_id => user.id).where("score >= ?", n).count
total_votes = Post.where("created_at >= ?", min_time).where(:uploader_id => user.id).count
ci_lower_bound(up_votes, total_votes, 0.95)
ci_lower_bound(up_votes, total_votes)
end
def self.deletion_confidence_interval_for(user)
deletions = Post.where(:uploader_id => user.id, :is_deleted => true).count
total = Post.where(:uploader_id => user.id).count
ci_lower_bound(deletions, total, 0.95)
def self.deletion_confidence_interval_for(user, days = nil)
date = (days || 30).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
ci_lower_bound(deletions, total)
end
def self.ci_lower_bound(pos, n, confidence)
def self.ci_lower_bound(pos, n, confidence = 0.95)
if n == 0
return 0
end