export and publish opendata demarches

This commit is contained in:
Christophe Robillard 2022-07-14 17:59:32 +02:00
parent 77a9a2ba12
commit b6c96301ef
3 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,18 @@
class Cron::ExportAndPublishDemarchesPubliquesJob < Cron::CronJob
self.schedule_expression = "every month at 3:00"
def perform(*args)
gzip_filepath = [
ENV.fetch('DATAGOUV_TMP_DIR', 'tmp'), '/',
Time.zone.now.to_formatted_s(:number),
'-demarches.json.gz'
].join
begin
DemarchesPubliquesExportService.new(gzip_filepath).call
APIDatagouv::API.upload(gzip_filepath)
ensure
FileUtils.rm(gzip_filepath)
end
end
end