OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Clean up webhook delivery logs older than 7 days
Oliver Güntheree65abaf2d0a
diff --git a/modules/webhooks/app/workers/cleanup_webhook_logs_job.rb b/modules/webhooks/app/workers/cleanup_webhook_logs_job.rbnew file mode 100644index 00000000000..510bb7866e7--- /dev/null+++ b/modules/webhooks/app/workers/cleanup_webhook_logs_job.rb@@ -0,0 +1,39 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2022 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++class CleanupWebhookLogsJob < ::Cron::CronJob+ # runs at 5:28 on Sunday+ self.cron_expression = '28 5 * * 7'++ # Clean any logs older than 7 days+ def perform+ ::Webhooks::Log+ .where('created_at < ?', 7.days.ago)+ .delete_all+ end+enddiff --git a/modules/webhooks/config/locales/en.yml b/modules/webhooks/config/locales/en.ymlindex cf795fc9260..5a03e57886d 100644--- a/modules/webhooks/config/locales/en.yml+++ b/modules/webhooks/config/locales/en.yml@@ -38,7 +38,7 @@ en:enabled_text: 'The webhook will emit payloads for the defined events below.'disabled_text: 'Click the edit button to activate the webhook.'deliveries:- no_results_table: No deliveries have been made for this webhook.+ no_results_table: No deliveries have been made for this webhook in the past days.title: 'Recent deliveries'time: 'Delivery time'form:diff --git a/modules/webhooks/lib/open_project/webhooks/engine.rb b/modules/webhooks/lib/open_project/webhooks/engine.rbindex 5bb43ea2aa3..6fd51b5d783 100644--- a/modules/webhooks/lib/open_project/webhooks/engine.rb+++ b/modules/webhooks/lib/open_project/webhooks/engine.rb@@ -50,5 +50,7 @@ module OpenProject::Webhooks::OpenProject::Webhooks::EventResources.subscribe!endend++ add_cron_jobs { CleanupWebhookLogsJob }endend