2014-06-27 12:26:03 -04:00
|
|
|
module Jobs
|
|
|
|
|
2014-09-24 20:19:26 -04:00
|
|
|
class Tl3Promotions < Jobs::Scheduled
|
2014-06-27 12:26:03 -04:00
|
|
|
daily at: 4.hours
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
# Demotions
|
|
|
|
demoted_user_ids = []
|
2017-11-23 15:55:44 -05:00
|
|
|
User.real.where(
|
|
|
|
trust_level: TrustLevel[3],
|
|
|
|
manual_locked_trust_level: nil,
|
|
|
|
group_locked_trust_level: nil
|
|
|
|
).find_each do |u|
|
2014-07-08 17:39:36 -04:00
|
|
|
# Don't demote too soon after being promoted
|
2014-09-24 20:19:26 -04:00
|
|
|
next if u.on_tl3_grace_period?
|
2014-07-08 17:39:36 -04:00
|
|
|
|
2014-09-05 01:20:39 -04:00
|
|
|
if Promotion.tl3_lost?(u)
|
2014-06-27 12:26:03 -04:00
|
|
|
demoted_user_ids << u.id
|
2014-09-05 01:20:39 -04:00
|
|
|
Promotion.new(u).change_trust_level!(TrustLevel[2])
|
2014-06-27 12:26:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Promotions
|
2018-02-05 17:54:07 -05:00
|
|
|
User.real.not_suspended.where(
|
|
|
|
trust_level: TrustLevel[2],
|
|
|
|
manual_locked_trust_level: nil,
|
|
|
|
group_locked_trust_level: nil
|
|
|
|
).where.not(id: demoted_user_ids)
|
|
|
|
.joins(:user_stat)
|
|
|
|
.where("user_stats.days_visited >= ?", SiteSetting.tl3_requires_days_visited)
|
|
|
|
.where("user_stats.topic_reply_count >= ?", SiteSetting.tl3_requires_topics_replied_to)
|
|
|
|
.where("user_stats.topics_entered >= ?", SiteSetting.tl3_requires_topics_viewed_all_time)
|
|
|
|
.where("user_stats.posts_read_count >= ?", SiteSetting.tl3_requires_posts_read_all_time)
|
|
|
|
.where("user_stats.likes_given >= ?", SiteSetting.tl3_requires_likes_given)
|
|
|
|
.where("user_stats.likes_received >= ?", SiteSetting.tl3_requires_likes_received)
|
|
|
|
.find_each do |u|
|
2014-09-05 01:20:39 -04:00
|
|
|
Promotion.new(u).review_tl2
|
2014-06-27 12:26:03 -04:00
|
|
|
end
|
2018-02-05 17:54:07 -05:00
|
|
|
|
2014-06-27 12:26:03 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|