From 486cdcb03947d74350f75617e6c7f138f4a97504 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Thu, 17 Sep 2015 11:35:50 -0700 Subject: [PATCH] fixes #2517: Janitor trial report broken --- app/logical/reports/janitor_trials.rb | 4 ++++ app/logical/reports/user_promotions.rb | 11 +++++++++++ app/views/janitor_trials/index.html.erb | 2 +- app/views/reports/contributors.html.erb | 8 +++++--- app/views/reports/user_promotions.html.erb | 16 ++++++---------- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/logical/reports/janitor_trials.rb b/app/logical/reports/janitor_trials.rb index 0c261fe2c..0c262d74e 100644 --- a/app/logical/reports/janitor_trials.rb +++ b/app/logical/reports/janitor_trials.rb @@ -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 diff --git a/app/logical/reports/user_promotions.rb b/app/logical/reports/user_promotions.rb index 756f2b950..4f0d66aeb 100644 --- a/app/logical/reports/user_promotions.rb +++ b/app/logical/reports/user_promotions.rb @@ -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 diff --git a/app/views/janitor_trials/index.html.erb b/app/views/janitor_trials/index.html.erb index aab9b0b3a..e37158688 100644 --- a/app/views/janitor_trials/index.html.erb +++ b/app/views/janitor_trials/index.html.erb @@ -6,7 +6,7 @@ User - Duration + Date diff --git a/app/views/reports/contributors.html.erb b/app/views/reports/contributors.html.erb index ca95cb838..104e12ece 100644 --- a/app/views/reports/contributors.html.erb +++ b/app/views/reports/contributors.html.erb @@ -10,7 +10,8 @@ User Level Uploads - deletion + Del Chance + Neg Score Chance @@ -19,8 +20,9 @@ <%= link_to_user user.user %> <%= user.level_string %> - <%= link_to user.post_upload_count, posts_path(:tags => "uploader:#{user.name} order:random", :limit => 200) %> - <%= link_to number_to_percentage(user.deletion_confidence_interval, :precision => 0), posts_path(:tags => "uploader:#{user.name} status:deleted", :limit => 200) %> + <%= link_to user.post_upload_count, posts_path(:tags => "user:#{user.name} order:random", :limit => 200) %> + <%= link_to number_to_percentage(user.deletion_confidence_interval, :precision => 0), posts_path(:tags => "user:#{user.name} status:deleted", :limit => 200) %> + <%= link_to number_to_percentage(user.negative_score_confidence_interval, :precision => 0), posts_path(:tags => "user:#{user.name} score:<0", :limit => 200) %> <% end %> <% end %> diff --git a/app/views/reports/user_promotions.html.erb b/app/views/reports/user_promotions.html.erb index 657db7ed2..dcf152656 100644 --- a/app/views/reports/user_promotions.html.erb +++ b/app/views/reports/user_promotions.html.erb @@ -11,11 +11,9 @@ Level Uploads Age - score:3+ - quartile score - median score - deletion - limit + Del Chance + Neg Score Chance + Limit @@ -24,12 +22,10 @@ <%= link_to_user user.user %> <%= user.level_string %> - <%= link_to user.post_upload_count, posts_path(:tags => "uploader:#{user.name} order:random", :limit => 200) %> + <%= link_to user.post_upload_count, posts_path(:tags => "user:#{user.name} order:random", :limit => 200) %> <%= time_ago_in_words user.created_at %> - <%= number_to_percentage user.confidence_interval_for(3), :precision => 0 %> - <%= user.quartile_score %> - <%= user.median_score %> - <%= link_to number_to_percentage(user.deletion_confidence_interval, :precision => 0), posts_path(:tags => "uploader:#{user.name} status:deleted", :limit => 200) %> + <%= link_to number_to_percentage(user.deletion_confidence_interval, :precision => 0), posts_path(:tags => "user:#{user.name} status:deleted", :limit => 200) %> + <%= link_to number_to_percentage(user.negative_score_confidence_interval, :precision => 0), posts_path(:tags => "user:#{user.name} score:<0", :limit => 200) %> <%= user.upload_limit %> <% end %>