improve janitor/promotion reports, fix bug with forum post counts
This commit is contained in:
@@ -15,11 +15,7 @@ class ForumPostsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if CurrentUser.is_janitor?
|
@query = ForumPost.search(params[:search])
|
||||||
@query = ForumPost.search(params[:search])
|
|
||||||
else
|
|
||||||
@query = ForumPost.active.search(params[:search])
|
|
||||||
end
|
|
||||||
@forum_posts = @query.order("forum_posts.id DESC").paginate(params[:page], :limit => params[:limit], :search_count => 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|
|
respond_with(@forum_posts) do |format|
|
||||||
format.xml do
|
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
|
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
|
end
|
||||||
|
|
||||||
def rating_e_percentage
|
def confidence_interval
|
||||||
100 * Post.where("approver_id = ? and created_at >= ? and rating = 'e'", user.id, since).count.to_f / [approval_count, 1].max
|
hits = Post.where("approver_id = ? and created_at >= ? and score >= 3", user.id, since).count
|
||||||
end
|
total = Post.where("approver_id = ? and created_at >= ?", user.id, since).count
|
||||||
|
Reports::UserPromotions.ci_lower_bound(hits, total, 0.95)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ module Reports
|
|||||||
end
|
end
|
||||||
|
|
||||||
def median_score
|
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
|
end
|
||||||
|
|
||||||
def quartile_score
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,18 @@
|
|||||||
<div id="a-user-promotions">
|
<div id="a-user-promotions">
|
||||||
<h1>Janitor Trial Report</h1>
|
<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>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-sort="string">User</th>
|
<th data-sort="string">User</th>
|
||||||
|
<th data-sort="int">Level</th>
|
||||||
<th data-sort="int">Approvals</th>
|
<th data-sort="int">Approvals</th>
|
||||||
<th data-sort="int">Deleted</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="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 data-sort="int" title="50% of approvals received this score or less">Median Score</th>
|
||||||
<th>Explicit %</th>
|
<th data-sort="int" title="Likelihood an approval will get a score of 3 or higher">score:3+</th>
|
||||||
<th>Questionable %</th>
|
|
||||||
<th>Safe %</th>
|
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -21,13 +22,12 @@
|
|||||||
<% @report.janitors.each do |janitor| %>
|
<% @report.janitors.each do |janitor| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to_user janitor.user %></td>
|
<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.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><%= link_to janitor.deleted_count, posts_path(:tags => "approver:#{janitor.user.name} status:deleted") %></td>
|
||||||
<td><%= janitor.percentile_25_score %></td>
|
<td><%= janitor.percentile_25_score %></td>
|
||||||
<td><%= janitor.percentile_50_score %></td>
|
<td><%= janitor.percentile_50_score %></td>
|
||||||
<td><%= number_to_percentage janitor.rating_e_percentage, :precision => 0 %></td>
|
<td><%= number_to_percentage janitor.confidence_interval, :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>
|
<td>
|
||||||
<% if CurrentUser.user.is_moderator? %>
|
<% if CurrentUser.user.is_moderator? %>
|
||||||
<%= link_to "Promote", promote_janitor_trial_path(janitor.trial), :method => :put, :remote => true %>
|
<%= link_to "Promote", promote_janitor_trial_path(janitor.trial), :method => :put, :remote => true %>
|
||||||
@@ -39,8 +39,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<p>All numbers shown are for the past 3 months.</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user