diff --git a/app/assets/stylesheets/specific/reports.css.scss b/app/assets/stylesheets/specific/reports.css.scss new file mode 100644 index 000000000..e69de29bb diff --git a/app/logical/reports/user_promotions.rb b/app/logical/reports/user_promotions.rb index 3fe16ae27..8885797f6 100644 --- a/app/logical/reports/user_promotions.rb +++ b/app/logical/reports/user_promotions.rb @@ -2,6 +2,19 @@ require 'statistics2' module Reports class UserPromotions + class User + attr_reader :user + delegate :name, :post_upload_count, :level_string, :level, :created_at, :to => :user + + def initialize(user) + @user = user + end + + def confidence_interval_for(n) + Reports::UserPromotions.confidence_interval_for(user, n) + end + end + def self.confidence_interval_for(user, n) up_votes = Post.where("created_at >= ?", min_time).where(:uploader_id => user.id).where("fav_count >= ?", n).count total_votes = Post.where("created_at >= ?", min_time).where(:uploader_id => user.id).count @@ -23,7 +36,7 @@ module Reports end def users - User.where("users.level < ? and users.post_upload_count >= 100", User::Levels::CONTRIBUTOR).order("created_at desc").limit(50) + ::User.where("users.level < ? and users.post_upload_count >= 100", ::User::Levels::CONTRIBUTOR).order("created_at desc").limit(50).map {|x| Reports::UserPromotions::User.new(x)} end end end diff --git a/app/views/reports/user_promotions.html.erb b/app/views/reports/user_promotions.html.erb index db89f783f..26ba0d0e1 100644 --- a/app/views/reports/user_promotions.html.erb +++ b/app/views/reports/user_promotions.html.erb @@ -4,29 +4,45 @@
Binomial proportion confidence interval for how likely a user's uploads will achieve a fav count of at at least n with 95% confidence within the past 30 days.
-| User | -Level | -score:1+ | -score:5+ | -score:10+ | +User | +Level | +Uploads | +Age | +score:1+ | +score:5+ | +score:10+ |
|---|---|---|---|---|---|---|---|---|---|---|---|
| <%= link_to user.name, user_path(user) %> | -<%= user.level_string %> | -<%= number_to_percentage Reports::UserPromotions.confidence_interval_for(user, 1), :precision => 0 %> | -<%= number_to_percentage Reports::UserPromotions.confidence_interval_for(user, 5), :precision => 0 %> | -<%= number_to_percentage Reports::UserPromotions.confidence_interval_for(user, 10), :precision => 0 %> | +<%= link_to user.name, user_path(user.user) %> | +<%= user.level_string %> | +<%= user.post_upload_count %> | +<%= time_ago_in_words user.created_at %> | +<%= number_to_percentage user.confidence_interval_for(1), :precision => 0 %> | +<%= number_to_percentage user.confidence_interval_for(5), :precision => 0 %> | +<%= number_to_percentage user.confidence_interval_for(10), :precision => 0 %> |