Welcome to mirror list, hosted at ThFree Co, Russian Federation.

prune_web_hook_logs_worker.rb « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: abfaabbf01d9cbb536bd87f71bc7715d2c6556c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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