improve janitor/promotion reports, fix bug with forum post counts
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
<div id="a-user-promotions">
|
||||
<h1>Janitor Trial Report</h1>
|
||||
|
||||
<table width="100%" class="striped" id="sortable" style="margin-bottom: 1em;">
|
||||
<p>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.</p>
|
||||
|
||||
<table width="100%" class="striped" id="sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-sort="string">User</th>
|
||||
<th data-sort="int">Level</th>
|
||||
<th data-sort="int">Approvals</th>
|
||||
<th data-sort="int">Deleted</th>
|
||||
<th data-sort="int" title="25% of approvals received this score or less">Quartile Score</th>
|
||||
<th data-sort="int" title="50% of approvals received this score or less">Median Score</th>
|
||||
<th>Explicit %</th>
|
||||
<th>Questionable %</th>
|
||||
<th>Safe %</th>
|
||||
<th data-sort="int" title="Likelihood an approval will get a score of 3 or higher">score:3+</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -21,13 +22,12 @@
|
||||
<% @report.janitors.each do |janitor| %>
|
||||
<tr>
|
||||
<td><%= link_to_user janitor.user %></td>
|
||||
<td data-sort-value="<%= user.level %>"><%= janitor.user.level_string %></td>
|
||||
<td><%= link_to janitor.approval_count, posts_path(:tags => "approver:#{janitor.user.name}") %></td>
|
||||
<td><%= link_to janitor.deleted_count, posts_path(:tags => "approver:#{janitor.user.name} status:deleted") %></td>
|
||||
<td><%= janitor.percentile_25_score %></td>
|
||||
<td><%= janitor.percentile_50_score %></td>
|
||||
<td><%= number_to_percentage janitor.rating_e_percentage, :precision => 0 %></td>
|
||||
<td><%= number_to_percentage janitor.rating_q_percentage, :precision => 0 %></td>
|
||||
<td><%= number_to_percentage janitor.rating_s_percentage, :precision => 0 %></td>
|
||||
<td><%= number_to_percentage janitor.confidence_interval, :precision => 0 %></td>
|
||||
<td>
|
||||
<% if CurrentUser.user.is_moderator? %>
|
||||
<%= link_to "Promote", promote_janitor_trial_path(janitor.trial), :method => :put, :remote => true %>
|
||||
@@ -39,8 +39,6 @@
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>All numbers shown are for the past 3 months.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user