From 017f914e2107919af55bc5b7944a3add3d2c3fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chai=CC=88b=20Martinez?= Date: Mon, 24 Jun 2019 14:57:06 +0200 Subject: [PATCH 1/4] Add admin roi low and high MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chaïb Martinez --- app/services/administrateur_usage_statistics_service.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/services/administrateur_usage_statistics_service.rb b/app/services/administrateur_usage_statistics_service.rb index e599d0d3b..e678ebc69 100644 --- a/app/services/administrateur_usage_statistics_service.rb +++ b/app/services/administrateur_usage_statistics_service.rb @@ -57,7 +57,10 @@ class AdministrateurUsageStatisticsService .map { |_procedure_id, count| count } .max || 0, nb_dossiers_traite: nb_dossiers_by_synthetic_state['termine'], - nb_dossiers_dossier_en_instruction: nb_dossiers_by_synthetic_state['en_instruction'] + nb_dossiers_dossier_en_instruction: nb_dossiers_by_synthetic_state['en_instruction'], + admin_roi_low: nb_dossiers * 7.04, + admin_roi_high: nb_dossiers * 17.25 + } if administrateur.current_sign_in_at.present? From 36114c07a97f8ba2e7fa297d46a9b3b1763b71de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chai=CC=88b=20Martinez?= Date: Mon, 24 Jun 2019 15:02:55 +0200 Subject: [PATCH 2/4] Add some test to admin roi calculation [fix #3986] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chaïb Martinez --- ...istrateur_usage_statistics_service_spec.rb | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/spec/services/administrateur_usage_statistics_service_spec.rb b/spec/services/administrateur_usage_statistics_service_spec.rb index 657089ed7..a582c1281 100644 --- a/spec/services/administrateur_usage_statistics_service_spec.rb +++ b/spec/services/administrateur_usage_statistics_service_spec.rb @@ -29,7 +29,9 @@ describe AdministrateurUsageStatisticsService do nb_dossiers: 0, nb_dossiers_max: 0, nb_dossiers_traite: 0, - nb_dossiers_dossier_en_instruction: 0 + nb_dossiers_dossier_en_instruction: 0, + admin_roi_low: 0, + admin_roi_high: 0 ) end end @@ -80,7 +82,9 @@ describe AdministrateurUsageStatisticsService do nb_dossiers: 0, nb_dossiers_max: 0, nb_dossiers_traite: 0, - nb_dossiers_dossier_en_instruction: 0 + nb_dossiers_dossier_en_instruction: 0, + admin_roi_low: 0, + admin_roi_high: 0 ) end end @@ -108,7 +112,9 @@ describe AdministrateurUsageStatisticsService do nb_dossiers: 21, nb_dossiers_max: 21, nb_dossiers_traite: 7, - nb_dossiers_dossier_en_instruction: 7 + nb_dossiers_dossier_en_instruction: 7, + admin_roi_low: 147.84, + admin_roi_high: 362.25 ) end end @@ -127,7 +133,9 @@ describe AdministrateurUsageStatisticsService do nb_dossiers: 0, nb_dossiers_max: 0, nb_dossiers_traite: 0, - nb_dossiers_dossier_en_instruction: 0 + nb_dossiers_dossier_en_instruction: 0, + admin_roi_low: 0, + admin_roi_high: 0 ) end end @@ -155,7 +163,9 @@ describe AdministrateurUsageStatisticsService do nb_dossiers: 0, nb_dossiers_max: 0, nb_dossiers_traite: 0, - nb_dossiers_dossier_en_instruction: 0 + nb_dossiers_dossier_en_instruction: 0, + admin_roi_low: 0, + admin_roi_high: 0 ) end end @@ -181,7 +191,9 @@ describe AdministrateurUsageStatisticsService do nb_dossiers: 3, nb_dossiers_max: 3, nb_dossiers_traite: 1, - nb_dossiers_dossier_en_instruction: 1 + nb_dossiers_dossier_en_instruction: 1, + admin_roi_low: 21.12, + admin_roi_high: 51.75 ) end end @@ -209,7 +221,9 @@ describe AdministrateurUsageStatisticsService do nb_dossiers: 21, nb_dossiers_max: 21, nb_dossiers_traite: 7, - nb_dossiers_dossier_en_instruction: 7 + nb_dossiers_dossier_en_instruction: 7, + admin_roi_low: 147.84, + admin_roi_high: 362.25 ) end end From e7b868c16ffcd3ddbd778ea2a69af53f5a6d4509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chai=CC=88b=20Martinez?= Date: Mon, 24 Jun 2019 15:49:25 +0200 Subject: [PATCH 3/4] Bug fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chaïb Martinez --- app/services/administrateur_usage_statistics_service.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/services/administrateur_usage_statistics_service.rb b/app/services/administrateur_usage_statistics_service.rb index e678ebc69..5cefeaf68 100644 --- a/app/services/administrateur_usage_statistics_service.rb +++ b/app/services/administrateur_usage_statistics_service.rb @@ -24,6 +24,7 @@ class AdministrateurUsageStatisticsService def administrateur_stats(administrateur) nb_dossiers_by_procedure_id = nb_dossiers_by_procedure_id(administrateur.id) nb_dossiers_by_synthetic_state = nb_dossiers_by_synthetic_state(administrateur.id) + nb_dossiers_roi = nb_dossiers_by_procedure_id.reject { |procedure_id, _count| is_brouillon(procedure_id) }.map { |_procedure_id, count| count }.sum result = { ds_sign_in_count: administrateur.sign_in_count, @@ -58,9 +59,8 @@ class AdministrateurUsageStatisticsService .max || 0, nb_dossiers_traite: nb_dossiers_by_synthetic_state['termine'], nb_dossiers_dossier_en_instruction: nb_dossiers_by_synthetic_state['en_instruction'], - admin_roi_low: nb_dossiers * 7.04, - admin_roi_high: nb_dossiers * 17.25 - + admin_roi_low: nb_dossiers_roi * 7.04, + admin_roi_high: nb_dossiers_roi * 17.25 } if administrateur.current_sign_in_at.present? From 3fee1c7644b6df7e6b767f6755e60aa16f1f18e7 Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Mon, 1 Jul 2019 11:14:26 +0200 Subject: [PATCH 4/4] Fix UpdateAdministrateurUsageStatisticsJob not being properly scheduled --- README.md | 2 +- app/jobs/update_administrateur_usage_statistics_job.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f113289d4..03a30208e 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ En local, un utilisateur de test est créé automatiquement, avec les identifian AutoArchiveProcedureJob.set(cron: "* * * * *").perform_later WeeklyOverviewJob.set(cron: "0 7 * * 1").perform_later AutoReceiveDossiersForProcedureJob.set(cron: "* * * * *").perform_later(procedure_declaratoire_id, Dossier.states.fetch(:en_instruction)) - SendinblueUpdateAdministrateursJob.set(cron: "0 10 * * *").perform_later + UpdateAdministrateurUsageStatisticsJob.set(cron: "0 10 * * *").perform_later FindDubiousProceduresJob.set(cron: "0 0 * * *").perform_later Administrateurs::ActivateBeforeExpirationJob.set(cron: "0 8 * * *").perform_later WarnExpiringDossiersJob.set(cron: "0 0 1 * *").perform_later diff --git a/app/jobs/update_administrateur_usage_statistics_job.rb b/app/jobs/update_administrateur_usage_statistics_job.rb index 940a98bae..a89fc365f 100644 --- a/app/jobs/update_administrateur_usage_statistics_job.rb +++ b/app/jobs/update_administrateur_usage_statistics_job.rb @@ -1,4 +1,6 @@ class UpdateAdministrateurUsageStatisticsJob < ApplicationJob + queue_as :cron + def perform AdministrateurUsageStatisticsService.new.update_administrateurs end