do not run ApiEntreprise jobs on missing etablissements

This commit is contained in:
clemkeirua 2020-09-28 14:37:34 +02:00
parent dd43c46e5e
commit 245e9e59c7
2 changed files with 14 additions and 0 deletions

View file

@ -3,6 +3,10 @@ class ApiEntreprise::Job < ApplicationJob
DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS = 5
# If by the time the job runs the Etablissement has been deleted
# (it can happen through EtablissementUpdateJob for instance), ignore the job
discard_on ActiveRecord::RecordNotFound
rescue_from(ApiEntreprise::API::ResourceNotFound) do |exception|
error(self, exception)
end