bug fix for janitor trial mailer
This commit is contained in:
@@ -26,20 +26,28 @@ class JanitorTrial < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.message_candidates!
|
def self.message_candidates!
|
||||||
admin = User.admins.first
|
admin = User.admins.first
|
||||||
|
n = 0
|
||||||
|
|
||||||
User.where("last_logged_in_at >= ? and created_at <= ? and email is not null and (favorite_count >= 300 OR post_upload_count >= 300) and bit_prefs & ? = 0", 1.week.ago, 6.months.ago, User.flag_value_for("can_approve_posts")).order("random()").limit(10).each do |user|
|
User.without_timeout do
|
||||||
if !Dmail.where("from_id = ? and to_id = ? and title = ?", admin.id, user.id, "Test Janitor Invitation").exists?
|
User.where("last_logged_in_at >= ? and created_at <= ? and email is not null and (favorite_count >= 300 OR post_upload_count >= 300) and bit_prefs & ? = 0", 1.week.ago, 6.months.ago, User.flag_value_for("can_approve_posts")).find_each do |user|
|
||||||
favorites = user.favorites.order("random()").limit(400).map(&:post_id)
|
if !Dmail.where("from_id = ? and to_id = ? and title = ?", admin.id, user.id, "Test Janitor Invitation").exists?
|
||||||
uploads = user.posts.order("random()").limit(400).map(&:id)
|
favorites = user.favorites.order("random()").limit(400).map(&:post_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
|
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
|
if p50 > 3
|
||||||
CurrentUser.scoped(admin, "127.0.0.1") do
|
n += 1
|
||||||
body = <<-EOS
|
if n > 8
|
||||||
Janitors on #{Danbooru.config.app_name} are responsible for helping maintain a high level of quality on the site. They approve uploads from other users and help with other moderation efforts. You would be expected at a minimum to approve a few posts a week. If you are interested, please respond to this message.
|
break
|
||||||
EOS
|
end
|
||||||
|
|
||||||
Dmail.create_split(:title => "Test Janitor Invitation", :body => body, :to_id => user.id)
|
CurrentUser.scoped(admin, "127.0.0.1") do
|
||||||
|
body = <<-EOS
|
||||||
|
Janitors on #{Danbooru.config.app_name} are responsible for helping maintain a high level of quality on the site. They approve uploads from other users and help with other moderation efforts. You would be expected at a minimum to approve a few posts a week. If you are interested, please respond to this message.
|
||||||
|
EOS
|
||||||
|
|
||||||
|
Dmail.create_split(:title => "Test Janitor Invitation", :body => body, :to_id => user.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user