diff --git a/app/jobs/annuaire_education_update_job.rb b/app/jobs/annuaire_education_update_job.rb deleted file mode 100644 index ffd06a27e..000000000 --- a/app/jobs/annuaire_education_update_job.rb +++ /dev/null @@ -1,16 +0,0 @@ -class AnnuaireEducationUpdateJob < ApplicationJob - def perform(champ) - external_id = champ.external_id - - if external_id.present? - data = APIEducation::AnnuaireEducationAdapter.new(external_id).to_params - - if data.present? - champ.data = data - else - champ.external_id = nil - end - champ.save! - end - end -end diff --git a/app/jobs/champ_fetch_external_data_job.rb b/app/jobs/champ_fetch_external_data_job.rb index ab8a09f7d..366586dda 100644 --- a/app/jobs/champ_fetch_external_data_job.rb +++ b/app/jobs/champ_fetch_external_data_job.rb @@ -1,6 +1,6 @@ class ChampFetchExternalDataJob < ApplicationJob - def perform(champ) - if champ.external_id.present? + def perform(champ, external_id) + if champ.external_id == external_id && champ.data.nil? data = champ.fetch_external_data if data.present? diff --git a/app/models/champ.rb b/app/models/champ.rb index e2e688021..ef9072e49 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -171,7 +171,7 @@ class Champ < ApplicationRecord def fetch_external_data_later if fetch_external_data? && external_id.present? && data.nil? - ChampFetchExternalDataJob.perform_later(self) + ChampFetchExternalDataJob.perform_later(self, external_id) end end