Démarches closes par mois : CRON Job

This commit is contained in:
Kara Diaby 2022-06-30 16:28:33 +02:00
parent 999059269e
commit 4a29162c6c

View file

@ -0,0 +1,19 @@
class Cron::Datagouv::ProcedureClosedByMonthJob < Cron::CronJob
include DatagouvCronSchedulableConcern
self.schedule_expression = "every month at 3:00"
FILE_NAME = "nb_procedures_closes_par_mois"
def perform(*args)
GenerateOpenDataCsvService.save_csv_to_tmp(FILE_NAME, data) do |file|
begin
APIDatagouv::API.upload(file, :statistics_dataset)
ensure
FileUtils.rm(file)
end
end
end
def data
Procedure.where(closed_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month).count
end
end