mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-01 03:17:53 -05:00
25 lines
641 B
Ruby
25 lines
641 B
Ruby
module Jobs
|
|
|
|
class LeaderPromotions < Jobs::Scheduled
|
|
daily at: 4.hours
|
|
|
|
def execute(args)
|
|
return unless Rails.env.test? # do nothing for now
|
|
|
|
# Demotions
|
|
demoted_user_ids = []
|
|
User.real.where(trust_level: TrustLevel.levels[:leader]).find_each do |u|
|
|
unless Promotion.leader_met?(u)
|
|
demoted_user_ids << u.id
|
|
Promotion.new(u).change_trust_level!(:regular)
|
|
end
|
|
end
|
|
|
|
# Promotions
|
|
User.real.where(trust_level: TrustLevel.levels[:regular]).where.not(id: demoted_user_ids).find_each do |u|
|
|
Promotion.new(u).review_regular
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|