demarches-normaliennes/app/jobs/champ_fetch_external_data_job.rb
sebastiencarceles f52554b5a3 review: update value with async fetch
1 - spec cover the job which fetches external data

2 - refactor the job with guard clauses

3 - delegate update operation to the champ itself

4 - annuaire education: override the update operation
to let the value be populated by the fetched data

5 - prefilling: don't fetch data synchronously
2023-02-28 14:53:08 +01:00

9 lines
280 B
Ruby

class ChampFetchExternalDataJob < ApplicationJob
def perform(champ, external_id)
return if champ.external_id != external_id
return if champ.data.present?
return if (data = champ.fetch_external_data).blank?
champ.update_with_external_data!(data: data)
end
end