Commit 91c06de2 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch '327613-remove-prune-webhook-logs-worker' into 'master'

Remove PruneWebHookLogsWorker class

See merge request gitlab-org/gitlab!62235
parents 256c51a3 c26acba2
......@@ -432,15 +432,6 @@
:weight: 1
:idempotent:
:tags: []
- :name: cronjob:prune_web_hook_logs
:worker_name: PruneWebHookLogsWorker
:feature_category: :integrations
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent:
:tags: []
- :name: cronjob:releases_manage_evidence
:worker_name: Releases::ManageEvidenceWorker
:feature_category: :release_evidence
......
# frozen_string_literal: true
# Worker that deletes a fixed number of outdated rows from the "web_hook_logs"
# table.
class PruneWebHookLogsWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
sidekiq_options retry: 3
# rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :integrations
# The maximum number of rows to remove in a single job.
DELETE_LIMIT = 50_000
def perform
cutoff_date = 90.days.ago.beginning_of_day
WebHookLog.created_before(cutoff_date).delete_with_limit(DELETE_LIMIT)
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe PruneWebHookLogsWorker do
describe '#perform' do
before do
hook = create(:project_hook)
create(:web_hook_log, web_hook: hook, created_at: 5.months.ago)
create(:web_hook_log, web_hook: hook, created_at: 4.months.ago)
create(:web_hook_log, web_hook: hook, created_at: 91.days.ago)
create(:web_hook_log, web_hook: hook, created_at: 89.days.ago)
create(:web_hook_log, web_hook: hook, created_at: 2.months.ago)
create(:web_hook_log, web_hook: hook, created_at: 1.month.ago)
create(:web_hook_log, web_hook: hook, response_status: '404')
end
it 'removes all web hook logs older than 90 days' do
described_class.new.perform
expect(WebHookLog.count).to eq(4)
expect(WebHookLog.last.response_status).to eq('404')
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