From 964f3829c688253418b3fe85da150a0a47320c00 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 8 Feb 2023 18:00:43 +0100 Subject: [PATCH 1/2] fix(export/job): race condition when export was already generated --- app/jobs/export_job.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/jobs/export_job.rb b/app/jobs/export_job.rb index bb34695fb..4854c5415 100644 --- a/app/jobs/export_job.rb +++ b/app/jobs/export_job.rb @@ -4,6 +4,8 @@ class ExportJob < ApplicationJob discard_on ActiveRecord::RecordNotFound def perform(export) + return if export.generated? + export.compute_with_safe_stale_for_purge do export.compute end From a4329b6699fb28bf6a7e4443c63336de79a0a487 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 8 Feb 2023 17:32:40 +0100 Subject: [PATCH 2/2] chore(export/job): set procedure_id for sentry --- app/jobs/export_job.rb | 4 ++++ app/models/export.rb | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/jobs/export_job.rb b/app/jobs/export_job.rb index 4854c5415..3884f97d7 100644 --- a/app/jobs/export_job.rb +++ b/app/jobs/export_job.rb @@ -3,6 +3,10 @@ class ExportJob < ApplicationJob discard_on ActiveRecord::RecordNotFound + before_perform do |job| + Sentry.set_tags(procedure_id: job.arguments.first.procedure.id) + end + def perform(export) return if export.generated? diff --git a/app/models/export.rb b/app/models/export.rb index 4f21b176d..fa8c6910e 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -163,6 +163,10 @@ class Export < ApplicationRecord end end + def procedure + groupe_instructeurs.first.procedure + end + private def load_snapshot! @@ -204,8 +208,4 @@ class Export < ApplicationRecord service.to_geo_json end end - - def procedure - groupe_instructeurs.first.procedure - end end