fixes #2517: Janitor trial report broken
This commit is contained in:
@@ -11,6 +11,10 @@ module Reports
|
||||
JanitorTrial.where(user_id: user.id).first
|
||||
end
|
||||
|
||||
def created_at
|
||||
trial.created_at
|
||||
end
|
||||
|
||||
def since
|
||||
3.months.ago
|
||||
end
|
||||
|
||||
@@ -18,6 +18,10 @@ module Reports
|
||||
Reports::UserPromotions.deletion_confidence_interval_for(user)
|
||||
end
|
||||
|
||||
def negative_score_confidence_interval
|
||||
Reports::UserPromotions.negative_score_confidence_interval_for(user)
|
||||
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 = ?", ::Reports::UserPromotions.min_time, user.id).to_i
|
||||
end
|
||||
@@ -40,6 +44,13 @@ module Reports
|
||||
ci_lower_bound(deletions, total)
|
||||
end
|
||||
|
||||
def self.negative_score_confidence_interval_for(user, days = nil)
|
||||
date = (days || 30).days.ago
|
||||
hits = Post.where("created_at >= ? and score < 0", date).where(:uploader_id => user.id).count
|
||||
total = Post.where("created_at >= ?", date).where(:uploader_id => user.id).count
|
||||
ci_lower_bound(hits, total)
|
||||
end
|
||||
|
||||
def self.ci_lower_bound(pos, n, confidence = 0.95)
|
||||
if n == 0
|
||||
return 0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Duration</th>
|
||||
<th>Date</th>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
<th data-sort="string">User</th>
|
||||
<th data-sort="int">Level</th>
|
||||
<th data-sort="int">Uploads</th>
|
||||
<th data-sort="int">deletion</th>
|
||||
<th data-sort="int">Del Chance</th>
|
||||
<th data-sort="int">Neg Score Chance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -19,8 +20,9 @@
|
||||
<tr>
|
||||
<td><%= link_to_user user.user %></td>
|
||||
<td data-sort-value="<%= user.level %>"><%= user.level_string %></td>
|
||||
<td><%= link_to user.post_upload_count, posts_path(:tags => "uploader:#{user.name} order:random", :limit => 200) %></td>
|
||||
<td><%= link_to number_to_percentage(user.deletion_confidence_interval, :precision => 0), posts_path(:tags => "uploader:#{user.name} status:deleted", :limit => 200) %></td>
|
||||
<td><%= link_to user.post_upload_count, posts_path(:tags => "user:#{user.name} order:random", :limit => 200) %></td>
|
||||
<td><%= link_to number_to_percentage(user.deletion_confidence_interval, :precision => 0), posts_path(:tags => "user:#{user.name} status:deleted", :limit => 200) %></td>
|
||||
<td><%= link_to number_to_percentage(user.negative_score_confidence_interval, :precision => 0), posts_path(:tags => "user:#{user.name} score:<0", :limit => 200) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -11,11 +11,9 @@
|
||||
<th data-sort="int">Level</th>
|
||||
<th data-sort="int">Uploads</th>
|
||||
<th data-sort="string">Age</th>
|
||||
<th data-sort="int">score:3+</th>
|
||||
<th data-sort="int" title="25% of uploads received this score or less">quartile score</th>
|
||||
<th data-sort="int" title="50% of uploads received this score or less">median score</th>
|
||||
<th data-sort="int">deletion</th>
|
||||
<th data-sort="int">limit</th>
|
||||
<th data-sort="int">Del Chance</th>
|
||||
<th data-sort="int">Neg Score Chance</th>
|
||||
<th data-sort="int">Limit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -24,12 +22,10 @@
|
||||
<tr>
|
||||
<td><%= link_to_user user.user %></td>
|
||||
<td data-sort-value="<%= user.level %>"><%= user.level_string %></td>
|
||||
<td><%= link_to user.post_upload_count, posts_path(:tags => "uploader:#{user.name} order:random", :limit => 200) %></td>
|
||||
<td><%= link_to user.post_upload_count, posts_path(:tags => "user:#{user.name} order:random", :limit => 200) %></td>
|
||||
<td data-sort-value="<%= user.created_at.to_formatted_s(:db) %>"><%= time_ago_in_words user.created_at %></td>
|
||||
<td><%= number_to_percentage user.confidence_interval_for(3), :precision => 0 %></td>
|
||||
<td><%= user.quartile_score %></td>
|
||||
<td><%= user.median_score %></td>
|
||||
<td><%= link_to number_to_percentage(user.deletion_confidence_interval, :precision => 0), posts_path(:tags => "uploader:#{user.name} status:deleted", :limit => 200) %></td>
|
||||
<td><%= link_to number_to_percentage(user.deletion_confidence_interval, :precision => 0), posts_path(:tags => "user:#{user.name} status:deleted", :limit => 200) %></td>
|
||||
<td><%= link_to number_to_percentage(user.negative_score_confidence_interval, :precision => 0), posts_path(:tags => "user:#{user.name} score:<0", :limit => 200) %></td>
|
||||
<td><%= user.upload_limit %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user