Administrateurs crées par mois : CRON Job

This commit is contained in:
Kara Diaby 2022-06-24 21:18:17 +02:00
parent 440ceddfd1
commit a0a3c6c0ee
2 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1,19 @@
class Cron::Datagouv::AdministrateurByMonthJob < Cron::CronJob
include DatagouvCronSchedulableConcern
self.schedule_expression = "every month at 3:00"
FILE_NAME = "nb_administrateurs_crees_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
Administrateur.where(created_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month).count
end
end

View file

@ -83,6 +83,7 @@ defaults: &defaults
api_url: <%= ENV['DATAGOUV_API_URL'] %> api_url: <%= ENV['DATAGOUV_API_URL'] %>
descriptif_demarches_dataset: <%= ENV['DATAGOUV_DESCRIPTIF_DEMARCHES_DATASET'] %> descriptif_demarches_dataset: <%= ENV['DATAGOUV_DESCRIPTIF_DEMARCHES_DATASET'] %>
descriptif_demarches_resource: <%= ENV['DATAGOUV_DESCRIPTIF_DEMARCHES_RESOURCE'] %> descriptif_demarches_resource: <%= ENV['DATAGOUV_DESCRIPTIF_DEMARCHES_RESOURCE'] %>
statistics_dataset: <%= ENV['DATAGOUV_STATISTICS_DATASET'] %>
development: development: