debian-mirror-gitlab/app/workers/prune_web_hook_logs_worker.rb

23 lines
668 B
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
# frozen_string_literal: true
# Worker that deletes a fixed number of outdated rows from the "web_hook_logs"
# table.
2020-04-08 14:13:33 +05:30
class PruneWebHookLogsWorker # rubocop:disable Scalability/IdempotentWorker
2018-11-08 19:23:39 +05:30
include ApplicationWorker
2020-03-13 15:44:24 +05:30
# rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
2018-11-08 19:23:39 +05:30
include CronjobQueue
2020-03-13 15:44:24 +05:30
# rubocop:enable Scalability/CronWorkerContext
2018-11-08 19:23:39 +05:30
2019-12-21 20:55:43 +05:30
feature_category :integrations
2018-11-08 19:23:39 +05:30
# The maximum number of rows to remove in a single job.
DELETE_LIMIT = 50_000
def perform
2020-03-13 15:44:24 +05:30
cutoff_date = 90.days.ago.beginning_of_day
WebHookLog.created_before(cutoff_date).delete_with_limit(DELETE_LIMIT)
2018-11-08 19:23:39 +05:30
end
end