export and publish opendata demarches
This commit is contained in:
parent
77a9a2ba12
commit
b6c96301ef
3 changed files with 49 additions and 0 deletions
18
app/jobs/cron/export_and_publish_demarches_publiques_job.rb
Normal file
18
app/jobs/cron/export_and_publish_demarches_publiques_job.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue