diff --git a/app/models/janitor_trial.rb b/app/models/janitor_trial.rb index d9b3e022d..6e8aeb4ca 100644 --- a/app/models/janitor_trial.rb +++ b/app/models/janitor_trial.rb @@ -27,11 +27,12 @@ class JanitorTrial < ActiveRecord::Base def self.message_candidates! admin = User.admins.first - User.where("last_logged_in_at >= ? and created_at <= ? and email is not null and favorite_count >= 200 and level between ? and ?", 1.week.ago, 6.months.ago, User::Levels::MEMBER, User::Levels::CONTRIBUTOR).order("random()").limit(5).each do |user| + User.where("last_logged_in_at >= ? and created_at <= ? and email is not null and (favorite_count >= 400 OR post_upload_count >= 400) and level between ? and ?", 1.week.ago, 6.months.ago, User::Levels::MEMBER, User::Levels::CONTRIBUTOR).order("random()").limit(5).each do |user| if !Dmail.where("from_id = ? and to_id = ? and title = ?", admin.id, user.id, "Test Janitor Invitation").exists? - favorites = user.favorites.order("random()").limit(400) - p50 = ActiveRecord::Base.select_value_sql("select percentile_cont(0.50) within group (order by score) from posts where id in (?)", favorites.map(&:post_id)).to_f - + favorites = user.favorites.order("random()").limit(400).map(&:post_id) + uploads = user.posts.order("random()").limit(400).map(&:id) + p50 = ActiveRecord::Base.select_value_sql("select percentile_cont(0.50) within group (order by score) from posts where id in (?)", favorites + uploads).to_f + if p50 > 3 and p50 <= 10 CurrentUser.scoped(admin, "127.0.0.1") do body = <<-EOS