add table sorting to promotion report

This commit is contained in:
r888888888
2013-07-02 17:11:35 -07:00
parent 2cfc5c296c
commit 3a31a5031b
4 changed files with 45 additions and 13 deletions

View File

@@ -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