add quartile+median scores to promotion report

This commit is contained in:
r888888888
2015-06-16 17:48:49 -07:00
parent b769f996be
commit b845d61db3
2 changed files with 13 additions and 1 deletions

View File

@@ -17,6 +17,14 @@ module Reports
def deletion_confidence_interval
Reports::UserPromotions.deletion_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 = ?", 30.days.ago, 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
end
end
def self.confidence_interval_for(user, n)
@@ -46,7 +54,7 @@ module Reports
end
def users
::User.where("users.level < ? and users.post_upload_count >= 150", ::User::Levels::CONTRIBUTOR).order("created_at desc").limit(50).map {|x| Reports::UserPromotions::User.new(x)}
::User.where("users.level < ? and users.post_upload_count >= 250", ::User::Levels::CONTRIBUTOR).order("created_at desc").limit(50).map {|x| Reports::UserPromotions::User.new(x)}
end
end
end

View File

@@ -13,6 +13,8 @@
<th data-sort="string">Age</th>
<th data-sort="int">score:3+</th>
<th data-sort="int">score:6+</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>
</tr>
</thead>
@@ -25,6 +27,8 @@
<td data-sort-value="<%= user.level %>"><%= user.level_string %></td>
<td><%= user.post_upload_count %></td>
<td data-sort-value="<%= user.created_at.to_formatted_s(:db) %>"><%= time_ago_in_words user.created_at %></td>
<td><%= user.quartile_score %></td>
<td><%= user.median_score %></td>
<td><%= number_to_percentage user.confidence_interval_for(3), :precision => 0 %></td>
<td><%= number_to_percentage user.confidence_interval_for(6), :precision => 0 %></td>
<td><%= number_to_percentage user.deletion_confidence_interval, :precision => 0 %></td>