Skip to content

Commit e86c8ce

Browse files
committed
add deletion column to promotion report
1 parent bc912ec commit e86c8ce

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

app/logical/reports/user_promotions.rb

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def initialize(user)
1313
def confidence_interval_for(n)
1414
Reports::UserPromotions.confidence_interval_for(user, n)
1515
end
16+
17+
def deletion_confidence_interval
18+
Reports::UserPromotions.deletion_confidence_interval(user)
19+
end
1620
end
1721

1822
def self.confidence_interval_for(user, n)
@@ -21,6 +25,12 @@ def self.confidence_interval_for(user, n)
2125
ci_lower_bound(up_votes, total_votes, 0.95)
2226
end
2327

28+
def self.deletion_confidence_interval_for(user)
29+
deletions = Post.where(:uploader_id => user.id, :is_deleted => true).count
30+
total = Post.where(:uploader_id => user.id).count
31+
ci_lower_bound(deletions, total, 0.95)
32+
end
33+
2434
def self.ci_lower_bound(pos, n, confidence)
2535
if n == 0
2636
return 0

app/views/reports/user_promotions.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<th data-sort="string">Age</th>
1414
<th data-sort="int">score:3+</th>
1515
<th data-sort="int">score:6+</th>
16+
<th data-sort="int">deletion</th>
1617
</tr>
1718
</thead>
1819
<tbody>
@@ -26,6 +27,7 @@
2627
<td data-sort-value="<%= user.created_at.to_formatted_s(:db) %>"><%= time_ago_in_words user.created_at %></td>
2728
<td><%= number_to_percentage user.confidence_interval_for(3), :precision => 0 %></td>
2829
<td><%= number_to_percentage user.confidence_interval_for(6), :precision => 0 %></td>
30+
<td><%= number_to_percentage user.deletion_confidence_interval, :precision => 0 %></td>
2931
</tr>
3032
<% end %>
3133
<% end %>

config/initializers/assets.rb

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Rails.application.config.assets.precompile += %w( stupidtable.js )

0 commit comments

Comments
 (0)