improve janitor/promotion reports, fix bug with forum post counts

This commit is contained in:
r888888888
2015-06-18 12:04:19 -07:00
parent 05dcb43fc2
commit d44495ff9e
4 changed files with 14 additions and 26 deletions

View File

@@ -31,16 +31,10 @@ module Reports
ActiveRecord::Base.select_value_sql("select percentile_cont(0.50) within group (order by score) from posts where created_at >= ? and approver_id = ?", since, user.id).to_i
end
def rating_e_percentage
100 * Post.where("approver_id = ? and created_at >= ? and rating = 'e'", user.id, since).count.to_f / [approval_count, 1].max
end
def rating_q_percentage
100 * Post.where("approver_id = ? and created_at >= ? and rating = 'q'", user.id, since).count.to_f / [approval_count, 1].max
end
def rating_s_percentage
100 * Post.where("approver_id = ? and created_at >= ? and rating = 's'", user.id, since).count.to_f / [approval_count, 1].max
def confidence_interval
hits = Post.where("approver_id = ? and created_at >= ? and score >= 3", user.id, since).count
total = Post.where("approver_id = ? and created_at >= ?", user.id, since).count
Reports::UserPromotions.ci_lower_bound(hits, total, 0.95)
end
end

View File

@@ -19,11 +19,11 @@ module Reports
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 = ?", 30.days.ago, user.id).to_i
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
def quartile_score
ActiveRecord::Base.select_value_sql("select percentile_cont(0.25) within group (order by score) from posts where created_at >= ? and uploader_id = ?", 30.days.ago, user.id).to_i
ActiveRecord::Base.select_value_sql("select percentile_cont(0.25) within group (order by score) from posts where created_at >= ? and uploader_id = ?", ::Reports::UserPromotions.min_time, user.id).to_i
end
end