demarches-normaliennes/app/jobs/champ_fetch_external_data_job.rb
Paul Chavard d24ee27cac Try to reduce the number of external data fetches
Only fetch external data if the external_id is the current one and data is not yet fetched
2021-03-11 14:56:37 +01:00

11 lines
267 B
Ruby

class ChampFetchExternalDataJob < ApplicationJob
def perform(champ, external_id)
if champ.external_id == external_id && champ.data.nil?
data = champ.fetch_external_data
if data.present?
champ.update!(data: data)
end
end
end
end