Class: PruneOldEventsWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue
Defined in:
app/workers/prune_old_events_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary collapse

DELETE_LIMIT =
10_000
CUTOFF_DATE =

Contribution calendar shows maximum 12 months of events, we retain 3 years for data integrity.

(3.years + 1.day).freeze

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Class Method Details

.pruning_enabled?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/workers/prune_old_events_worker.rb', line 19

def self.pruning_enabled?
  Feature.enabled?(:ops_prune_old_events, type: :ops)
end

Instance Method Details

#performObject



23
24
25
26
27
28
29
30
31
# File 'app/workers/prune_old_events_worker.rb', line 23

def perform
  if self.class.pruning_enabled?
    cutoff_date = CUTOFF_DATE.ago

    Event.unscoped.created_before(cutoff_date).delete_with_limit(DELETE_LIMIT)
  else
    Gitlab::AppLogger.info(":ops_prune_old_events is disabled, skipping.")
  end
end