From d2463a7a70cd989308742a6c667965814524467a Mon Sep 17 00:00:00 2001 From: Eric Guo Date: Thu, 7 Mar 2024 11:43:59 +0800 Subject: [PATCH] Revert "fix[Op#53019]: Good Job ClearOldMergeRequestsJob" This reverts commit a5eb5280dbf1a5448e74201bd40ed3fe6128d243. --- .../app/workers/cron/clear_old_merge_requests_job.rb | 5 ++++- .../lib/open_project/gitlab_integration/engine.rb | 10 +++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/gitlab_integration/app/workers/cron/clear_old_merge_requests_job.rb b/modules/gitlab_integration/app/workers/cron/clear_old_merge_requests_job.rb index fa30113be3af..5a588b4a75d9 100644 --- a/modules/gitlab_integration/app/workers/cron/clear_old_merge_requests_job.rb +++ b/modules/gitlab_integration/app/workers/cron/clear_old_merge_requests_job.rb @@ -30,9 +30,12 @@ #++ module Cron - class ClearOldMergeRequestsJob < ApplicationJob + class ClearOldMergeRequestsJob < CronJob priority_number :low + # runs at 1:25 nightly + self.cron_expression = "25 1 * * *" + def perform GitlabMergeRequest.without_work_package .find_each(&:destroy!) diff --git a/modules/gitlab_integration/lib/open_project/gitlab_integration/engine.rb b/modules/gitlab_integration/lib/open_project/gitlab_integration/engine.rb index 48b2c0b84582..89377b7981ff 100644 --- a/modules/gitlab_integration/lib/open_project/gitlab_integration/engine.rb +++ b/modules/gitlab_integration/lib/open_project/gitlab_integration/engine.rb @@ -100,13 +100,9 @@ class Engine < ::Rails::Engine mount ::API::V3::GitlabIssues::GitlabIssuesByWorkPackageAPI end - add_cron_jobs do - { - "Cron::ClearOldMergeRequestsJob": { - cron: "25 1 * * *", # runs at 1:25 nightly - class: ::Cron::ClearOldMergeRequestsJob.name - } - } + config.to_prepare do + # Register the cron job to clean up old gitlab merge requests + ::Cron::CronJob.register! ::Cron::ClearOldMergeRequestsJob end end end