2014-06-28 00:26:03 +08:00
|
|
|
module Jobs
|
|
|
|
|
2014-09-25 08:19:26 +08:00
|
|
|
class Tl3Promotions < Jobs::Scheduled
|
2014-06-28 00:26:03 +08:00
|
|
|
daily at: 4.hours
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
# Demotions
|
|
|
|
demoted_user_ids = []
|
2017-11-24 04:55:44 +08:00
|
|
|
User.real.where(
|
|
|
|
trust_level: TrustLevel[3],
|
|
|
|
manual_locked_trust_level: nil,
|
|
|
|
group_locked_trust_level: nil
|
|
|
|
).find_each do |u|
|
2014-07-09 05:39:36 +08:00
|
|
|
# Don't demote too soon after being promoted
|
2014-09-25 08:19:26 +08:00
|
|
|
next if u.on_tl3_grace_period?
|
2014-07-09 05:39:36 +08:00
|
|
|
|
2014-09-05 13:20:39 +08:00
|
|
|
if Promotion.tl3_lost?(u)
|
2014-06-28 00:26:03 +08:00
|
|
|
demoted_user_ids << u.id
|
2014-09-05 13:20:39 +08:00
|
|
|
Promotion.new(u).change_trust_level!(TrustLevel[2])
|
2014-06-28 00:26:03 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Promotions
|
2017-11-24 04:55:44 +08:00
|
|
|
User.real.where(
|
|
|
|
trust_level: TrustLevel[2],
|
|
|
|
manual_locked_trust_level: nil,
|
|
|
|
group_locked_trust_level: nil
|
|
|
|
).where.not(id: demoted_user_ids).find_each do |u|
|
2014-09-05 13:20:39 +08:00
|
|
|
Promotion.new(u).review_tl2
|
2014-06-28 00:26:03 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|