From 3cd9a142670a1b127f72ae05534ee3aa5492e90f Mon Sep 17 00:00:00 2001 From: manu vasconcelos Date: Thu, 12 Sep 2024 15:38:29 -0300 Subject: [PATCH] update how we notify Sentry - call the notify inside else, before I was always sending a sentry error - it's better to send the project_media_id to Sentry, even if there isn't a project media object, an id might exist --- app/models/project_media.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/project_media.rb b/app/models/project_media.rb index 83b3ca02b..f5b646746 100644 --- a/app/models/project_media.rb +++ b/app/models/project_media.rb @@ -532,12 +532,13 @@ def self.create_tags_in_background(**params) params = params.with_indifferent_access project_media = ProjectMedia.find_by_id(params['project_media_id']) - unless project_media.nil? + if !project_media.nil? tags = JSON.parse(params['tags_json']) tags.each { |tag| Tag.create! annotated: project_media, tag: tag.strip, skip_check_ability: true } + else + error = StandardError.new("[ProjectMedia] Exception creating project media's tags in background. Project media is nil.") + CheckSentry.notify(error, project_media_id: params['project_media_id']) end - error = StandardError.new("[ProjectMedia] Exception creating project media's tags in background. Project media is nil.") - CheckSentry.notify(error) end # private