Commit 536c1e40 authored by Douwe Maan's avatar Douwe Maan

Remove RemoveOldWebHookLogsWorker

parent 40343096
......@@ -10,7 +10,6 @@
- cronjob:prune_old_events
- cronjob:remove_expired_group_links
- cronjob:remove_expired_members
- cronjob:remove_old_web_hook_logs
- cronjob:remove_unreferenced_lfs_objects
- cronjob:repository_archive_cache
- cronjob:repository_check_dispatch
......
# frozen_string_literal: true
class RemoveOldWebHookLogsWorker
include ApplicationWorker
include CronjobQueue
WEB_HOOK_LOG_LIFETIME = 2.days
# rubocop: disable DestroyAll
def perform
WebHookLog.destroy_all(['created_at < ?', Time.now - WEB_HOOK_LOG_LIFETIME])
end
# rubocop: enable DestroyAll
end
---
title: Remove old webhook logs after 90 days, as documented, instead of after 2
merge_request:
author:
type: fixed
......@@ -302,10 +302,6 @@ Settings.cron_jobs['gitlab_usage_ping_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['gitlab_usage_ping_worker']['cron'] ||= Settings.__send__(:cron_for_usage_ping)
Settings.cron_jobs['gitlab_usage_ping_worker']['job_class'] = 'GitlabUsagePingWorker'
Settings.cron_jobs['remove_old_web_hook_logs_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['remove_old_web_hook_logs_worker']['cron'] ||= '40 0 * * *'
Settings.cron_jobs['remove_old_web_hook_logs_worker']['job_class'] = 'RemoveOldWebHookLogsWorker'
Settings.cron_jobs['stuck_merge_jobs_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['stuck_merge_jobs_worker']['cron'] ||= '0 */2 * * *'
Settings.cron_jobs['stuck_merge_jobs_worker']['job_class'] = 'StuckMergeJobsWorker'
......
require 'spec_helper'
describe RemoveOldWebHookLogsWorker do
subject { described_class.new }
describe '#perform' do
let!(:week_old_record) { create(:web_hook_log, created_at: Time.now - 1.week) }
let!(:three_days_old_record) { create(:web_hook_log, created_at: Time.now - 3.days) }
let!(:one_day_old_record) { create(:web_hook_log, created_at: Time.now - 1.day) }
it 'removes web hook logs older than 2 days' do
subject.perform
expect(WebHookLog.all).to include(one_day_old_record)
expect(WebHookLog.all).not_to include(week_old_record, three_days_old_record)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment