mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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)
|
def execute(args)
|
||||||
return unless SiteSetting.enable_badges?
|
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
|
start_date = args[:start_date] || 1.year.ago
|
||||||
end_date = start_date + 1.year
|
end_date = start_date + 1.year
|
||||||
@ -31,7 +33,6 @@ module Jobs
|
|||||||
HAVING COUNT(p.id) > 0 AND COUNT(ub.id) = 0
|
HAVING COUNT(p.id) > 0 AND COUNT(ub.id) = 0
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
badge = Badge.find(Badge::Anniversary)
|
|
||||||
user_ids = results.map { |r| r['user_id'].to_i }
|
user_ids = results.map { |r| r['user_id'].to_i }
|
||||||
|
|
||||||
User.where(id: user_ids).find_each do |user|
|
User.where(id: user_ids).find_each do |user|
|
||||||
|
Loading…
Reference in New Issue
Block a user