From d44495ff9eef6606eb2ceb3f227dd4771c708e8a Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 18 Jun 2015 12:04:19 -0700 Subject: [PATCH] improve janitor/promotion reports, fix bug with forum post counts --- app/controllers/forum_posts_controller.rb | 6 +----- app/logical/reports/janitor_trials.rb | 14 ++++---------- app/logical/reports/user_promotions.rb | 4 ++-- app/views/reports/janitor_trials.html.erb | 16 +++++++--------- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/app/controllers/forum_posts_controller.rb b/app/controllers/forum_posts_controller.rb index 32ed122ed..ef2ca91fb 100644 --- a/app/controllers/forum_posts_controller.rb +++ b/app/controllers/forum_posts_controller.rb @@ -15,11 +15,7 @@ class ForumPostsController < ApplicationController end def index - if CurrentUser.is_janitor? - @query = ForumPost.search(params[:search]) - else - @query = ForumPost.active.search(params[:search]) - end + @query = ForumPost.search(params[:search]) @forum_posts = @query.order("forum_posts.id DESC").paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@forum_posts) do |format| format.xml do diff --git a/app/logical/reports/janitor_trials.rb b/app/logical/reports/janitor_trials.rb index 772f99717..a23afa994 100644 --- a/app/logical/reports/janitor_trials.rb +++ b/app/logical/reports/janitor_trials.rb @@ -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 diff --git a/app/logical/reports/user_promotions.rb b/app/logical/reports/user_promotions.rb index ad35d32d8..ac996e08c 100644 --- a/app/logical/reports/user_promotions.rb +++ b/app/logical/reports/user_promotions.rb @@ -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 diff --git a/app/views/reports/janitor_trials.html.erb b/app/views/reports/janitor_trials.html.erb index 05f228dfb..643b843b1 100644 --- a/app/views/reports/janitor_trials.html.erb +++ b/app/views/reports/janitor_trials.html.erb @@ -2,17 +2,18 @@

Janitor Trial Report

- +

All numbers shown are for the past 3 months. Binomial proportion confidence interval for how likely a janitor's approvals will achieve a score of at at least n with 95% confidence.

+ +
+ - - - + @@ -21,13 +22,12 @@ <% @report.janitors.each do |janitor| %> + - - - +
UserLevel Approvals Deleted Quartile Score Median ScoreExplicit %Questionable %Safe %score:3+
<%= link_to_user janitor.user %><%= janitor.user.level_string %> <%= link_to janitor.approval_count, posts_path(:tags => "approver:#{janitor.user.name}") %> <%= link_to janitor.deleted_count, posts_path(:tags => "approver:#{janitor.user.name} status:deleted") %> <%= janitor.percentile_25_score %> <%= janitor.percentile_50_score %><%= number_to_percentage janitor.rating_e_percentage, :precision => 0 %><%= number_to_percentage janitor.rating_q_percentage, :precision => 0 %><%= number_to_percentage janitor.rating_s_percentage, :precision => 0 %><%= number_to_percentage janitor.confidence_interval, :precision => 0 %> <% if CurrentUser.user.is_moderator? %> <%= link_to "Promote", promote_janitor_trial_path(janitor.trial), :method => :put, :remote => true %> @@ -39,8 +39,6 @@ <% end %>
- -

All numbers shown are for the past 3 months.