2014-07-01 18:46:28 -05:00
|
|
|
module Jobs
|
|
|
|
|
|
|
|
class BadgeGrant < Jobs::Scheduled
|
2014-07-10 23:17:01 -05:00
|
|
|
def self.run
|
|
|
|
self.new.execute(nil)
|
|
|
|
end
|
|
|
|
|
2014-07-01 18:46:28 -05:00
|
|
|
every 1.day
|
|
|
|
|
|
|
|
def execute(args)
|
2014-09-02 15:12:27 -05:00
|
|
|
return unless SiteSetting.enable_badges
|
2014-10-07 18:26:18 -05:00
|
|
|
|
2016-01-18 14:41:12 -06:00
|
|
|
Badge.enabled.find_each do |b|
|
2015-03-28 20:36:05 -05:00
|
|
|
begin
|
|
|
|
BadgeGranter.backfill(b)
|
|
|
|
rescue => ex
|
|
|
|
# TODO - expose errors in UI
|
|
|
|
Discourse.handle_job_exception(ex, error_context({}, code_desc: 'Exception granting badges', extra: {badge_id: b.id}))
|
|
|
|
end
|
2014-07-03 02:29:44 -05:00
|
|
|
end
|
2014-10-07 18:26:18 -05:00
|
|
|
|
|
|
|
BadgeGranter.revoke_ungranted_titles!
|
2014-07-01 18:46:28 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|