From 6ce26ab4d8499ba8a78a67158e98da47ecd4a8a5 Mon Sep 17 00:00:00 2001 From: riking Date: Sat, 28 Mar 2015 18:36:05 -0700 Subject: [PATCH] FIX: Don't stop the badge grant after the first failure --- app/jobs/scheduled/badge_grant.rb | 7 ++++++- app/services/badge_granter.rb | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/jobs/scheduled/badge_grant.rb b/app/jobs/scheduled/badge_grant.rb index 32aa9deca..5f218f911 100644 --- a/app/jobs/scheduled/badge_grant.rb +++ b/app/jobs/scheduled/badge_grant.rb @@ -11,7 +11,12 @@ module Jobs return unless SiteSetting.enable_badges Badge.all.each do |b| - BadgeGranter.backfill(b) + 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 end BadgeGranter.revoke_ungranted_titles! diff --git a/app/services/badge_granter.rb b/app/services/badge_granter.rb index 9c17abaa9..b34b6543b 100644 --- a/app/services/badge_granter.rb +++ b/app/services/badge_granter.rb @@ -120,7 +120,9 @@ class BadgeGranter user_ids = list.map{|i| i["user_ids"]}.flatten.compact.uniq next unless post_ids.present? || user_ids.present? - find_by_type(type).each{|badge| backfill(badge, post_ids: post_ids, user_ids: user_ids)} + find_by_type(type).each{ |badge| + backfill(badge, post_ids: post_ids, user_ids: user_ids) + } end end