2018-06-26 16:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Worker that deletes a fixed number of outdated rows from the "web_hook_logs"
|
|
|
|
# table.
|
2020-02-19 18:09:10 +00:00
|
|
|
class PruneWebHookLogsWorker # rubocop:disable Scalability/IdempotentWorker
|
2018-06-26 16:24:42 +00:00
|
|
|
include ApplicationWorker
|
2020-02-10 12:08:59 +00:00
|
|
|
# rubocop:disable Scalability/CronWorkerContext
|
|
|
|
# This worker does not perform work scoped to a context
|
|
|
|
include CronjobQueue
|
|
|
|
# rubocop:enable Scalability/CronWorkerContext
|
2018-06-26 16:24:42 +00:00
|
|
|
|
2019-10-18 11:11:44 +00:00
|
|
|
feature_category :integrations
|
|
|
|
|
2018-06-26 16:24:42 +00:00
|
|
|
# The maximum number of rows to remove in a single job.
|
|
|
|
DELETE_LIMIT = 50_000
|
|
|
|
|
|
|
|
def perform
|
2020-02-03 09:08:42 +00:00
|
|
|
cutoff_date = 90.days.ago.beginning_of_day
|
|
|
|
|
|
|
|
WebHookLog.created_before(cutoff_date).delete_with_limit(DELETE_LIMIT)
|
2018-06-26 16:24:42 +00:00
|
|
|
end
|
|
|
|
end
|