demarches-normaliennes/app/jobs/api_entreprise/effectifs_job.rb

23 lines
731 B
Ruby
Raw Normal View History

2020-06-02 20:13:38 +02:00
class ApiEntreprise::EffectifsJob < ApiEntreprise::Job
2020-05-14 10:56:26 +02:00
def perform(etablissement_id, procedure_id)
etablissement = Etablissement.find(etablissement_id)
2020-06-09 18:49:09 +02:00
# april 2020 is at the moment the most actual info for effectifs endpoint
etablissement_params = ApiEntreprise::EffectifsAdapter.new(etablissement.siret, procedure_id, "2020", "04").to_params
2020-05-14 10:56:26 +02:00
etablissement.update!(etablissement_params)
end
private
def get_current_valid_month_for_effectif
today = Date.today
date_update = Date.new(today.year, today.month, 15)
if today >= date_update
[today.strftime("%Y"), today.strftime("%m")]
else
date = today - 1.month
[date.strftime("%Y"), date.strftime("%m")]
end
end
end