From 8bbb4c13f1f86901f6ff10b73724535f0138e976 Mon Sep 17 00:00:00 2001 From: Michael Bryzek Date: Fri, 7 Jun 2024 19:19:06 -0400 Subject: [PATCH] Schedule purge task --- api/app/actors/PeriodicActor.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/api/app/actors/PeriodicActor.scala b/api/app/actors/PeriodicActor.scala index 2b4f3a44c..cbb0759b5 100644 --- a/api/app/actors/PeriodicActor.scala +++ b/api/app/actors/PeriodicActor.scala @@ -7,7 +7,7 @@ import play.api.{Environment, Mode} import javax.inject.Inject import scala.concurrent.ExecutionContext -import scala.concurrent.duration.{FiniteDuration, HOURS} +import scala.concurrent.duration.{FiniteDuration, HOURS, SECONDS} class PeriodicActor @Inject() ( tasksDao: InternalTasksDao, @@ -31,13 +31,21 @@ class PeriodicActor @Inject() ( context.system.scheduler.scheduleWithFixedDelay(finalInitial, interval, self, UpsertTask(taskType)) } + private[this] def scheduleOnce(taskType: TaskType): Unit = { + context.system.scheduler.scheduleOnce(FiniteDuration(10, SECONDS)) { + UpsertTask(taskType) + } + } + + private[this] val cancellables: Seq[Cancellable] = { import TaskType._ + scheduleOnce(ScheduleMigrateVersions) Seq( schedule(CleanupDeletions, FiniteDuration(1, HOURS)), - schedule(ScheduleMigrateVersions, FiniteDuration(12, HOURS)), schedule(ScheduleSyncGeneratorServices, FiniteDuration(1, HOURS)), schedule(CheckInvariants, FiniteDuration(1, HOURS)), + schedule(PurgeOldDeleted, FiniteDuration(1, HOURS))(FiniteDuration(5, SECONDS)), ) }