mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 02:29:49 +08:00
PERF: Terminate scheduled job earlier if badge is not enabled.
This commit is contained in:
parent
69b2d64334
commit
1ab60d83df
@ -4,6 +4,8 @@ module Jobs
|
||||
|
||||
def execute(args)
|
||||
return unless SiteSetting.enable_badges?
|
||||
badge = Badge.find_by(id: Badge::Anniversary, enabled: true)
|
||||
return unless badge
|
||||
|
||||
start_date = args[:start_date] || 1.year.ago
|
||||
end_date = start_date + 1.year
|
||||
@ -31,7 +33,6 @@ module Jobs
|
||||
HAVING COUNT(p.id) > 0 AND COUNT(ub.id) = 0
|
||||
SQL
|
||||
|
||||
badge = Badge.find(Badge::Anniversary)
|
||||
user_ids = results.map { |r| r['user_id'].to_i }
|
||||
|
||||
User.where(id: user_ids).find_each do |user|
|
||||
|
Loading…
x
Reference in New Issue
Block a user