Démarches supprimées par mois : CRON Job
This commit is contained in:
parent
4a29162c6c
commit
dc1d0ce071
1 changed files with 19 additions and 0 deletions
19
app/jobs/cron/datagouv/procedure_deleted_by_month_job.rb
Normal file
19
app/jobs/cron/datagouv/procedure_deleted_by_month_job.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class Cron::Datagouv::ProcedureDeletedByMonthJob < Cron::CronJob
|
||||
include DatagouvCronSchedulableConcern
|
||||
self.schedule_expression = "every month at 3:00"
|
||||
FILE_NAME = "nb_procedures_supprimees_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(hidden_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month).count
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue