diff --git a/app/config/TaskConfiguration.scala b/app/config/TaskConfiguration.scala index e0dbf50f..840c29c5 100644 --- a/app/config/TaskConfiguration.scala +++ b/app/config/TaskConfiguration.scala @@ -11,7 +11,8 @@ case class TaskConfiguration( reportClosure: ReportClosureTaskConfiguration, reportReminders: ReportRemindersTaskConfiguration, inactiveAccounts: InactiveAccountsTaskConfiguration, - companyUpdate: CompanyUpdateTaskConfiguration + companyUpdate: CompanyUpdateTaskConfiguration, + probe: ProbeConfiguration ) case class SubscriptionTaskConfiguration(startTime: LocalTime, startDay: DayOfWeek) @@ -38,3 +39,5 @@ case class ReportRemindersTaskConfiguration( mailReminderDelay: Period // 7days. ) + +case class ProbeConfiguration(active: Boolean) diff --git a/app/loader/SignalConsoApplicationLoader.scala b/app/loader/SignalConsoApplicationLoader.scala index 2ec1c5d0..f83f56ff 100644 --- a/app/loader/SignalConsoApplicationLoader.scala +++ b/app/loader/SignalConsoApplicationLoader.scala @@ -701,23 +701,28 @@ class SignalConsoComponents( ) // Probes - val probeRepository = new ProbeRepository(dbConfig) - new LowRateReponseConsoTask( - actorSystem, - applicationConfiguration.task, - taskRepository, - probeRepository, - userRepository, - mailService - ).schedule() - new LowRateLanceurDAlerteTask( - actorSystem, - applicationConfiguration.task, - taskRepository, - probeRepository, - userRepository, - mailService - ).schedule() + if (applicationConfiguration.task.probe.active) { + logger.debug("Probes are enabled") + val probeRepository = new ProbeRepository(dbConfig) + new LowRateReponseConsoTask( + actorSystem, + applicationConfiguration.task, + taskRepository, + probeRepository, + userRepository, + mailService + ).schedule() + new LowRateLanceurDAlerteTask( + actorSystem, + applicationConfiguration.task, + taskRepository, + probeRepository, + userRepository, + mailService + ).schedule() + } else { + logger.debug("Probes are disabled") + } // Routes lazy val router: Router = diff --git a/app/tasks/probe/LowRateLanceurDAlerteTask.scala b/app/tasks/probe/LowRateLanceurDAlerteTask.scala index 7dcf60e8..57aeb044 100644 --- a/app/tasks/probe/LowRateLanceurDAlerteTask.scala +++ b/app/tasks/probe/LowRateLanceurDAlerteTask.scala @@ -26,7 +26,7 @@ class LowRateLanceurDAlerteTask( userRepository: UserRepositoryInterface, mailService: MailService )(implicit executionContext: ExecutionContext) - extends ScheduledTask(10, "low_rate_lanceur_dalerte", taskRepository, actorSystem, taskConfiguration) { + extends ScheduledTask(101, "low_rate_lanceur_dalerte", taskRepository, actorSystem, taskConfiguration) { override val logger: Logger = Logger(this.getClass) override val startTime: LocalTime = LocalTime.of(2, 0) diff --git a/app/tasks/probe/LowRateReponseConsoTask.scala b/app/tasks/probe/LowRateReponseConsoTask.scala index 1bfaf777..7488e8b9 100644 --- a/app/tasks/probe/LowRateReponseConsoTask.scala +++ b/app/tasks/probe/LowRateReponseConsoTask.scala @@ -26,7 +26,7 @@ class LowRateReponseConsoTask( userRepository: UserRepositoryInterface, mailService: MailService )(implicit executionContext: ExecutionContext) - extends ScheduledTask(10, "low_rate_reponse_conso", taskRepository, actorSystem, taskConfiguration) { + extends ScheduledTask(100, "low_rate_reponse_conso", taskRepository, actorSystem, taskConfiguration) { override val logger: Logger = Logger(this.getClass) override val startTime: LocalTime = LocalTime.of(2, 0) diff --git a/conf/common/task.conf b/conf/common/task.conf index c2739631..a6dfec4c 100644 --- a/conf/common/task.conf +++ b/conf/common/task.conf @@ -36,4 +36,9 @@ task { etablissement-api-key = ${ETABLISSEMENT_API_KEY} } + probe { + active = true + active = ${?SIGNAL_CONSO_SCHEDULED_PROBES_ACTIVE} + } + } \ No newline at end of file diff --git a/test/tasks/report/ReportRemindersTaskUnitSpec.scala b/test/tasks/report/ReportRemindersTaskUnitSpec.scala index bfa31e31..b18b3a93 100644 --- a/test/tasks/report/ReportRemindersTaskUnitSpec.scala +++ b/test/tasks/report/ReportRemindersTaskUnitSpec.scala @@ -1,6 +1,7 @@ package tasks.report import akka.actor.testkit.typed.scaladsl.ActorTestKit +import config.ProbeConfiguration import config.ReportRemindersTaskConfiguration import config.TaskConfiguration import models.company.AccessLevel @@ -49,7 +50,8 @@ class ReportRemindersTaskUnitSpec extends Specification with FutureMatchers { mailReminderDelay = Period.ofDays(7) ), inactiveAccounts = null, - companyUpdate = null + companyUpdate = null, + probe = ProbeConfiguration(false) ) val testKit = ActorTestKit()