Class: DeleteDiffFilesWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker
Defined in:
app/workers/delete_diff_files_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(merge_request_diff_id) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/workers/delete_diff_files_worker.rb', line 9

def perform(merge_request_diff_id)
  merge_request_diff = MergeRequestDiff.find(merge_request_diff_id)

  return if merge_request_diff.without_files?

  MergeRequestDiff.transaction do
    MergeRequestDiffFile
      .where(merge_request_diff_id: merge_request_diff.id)
      .delete_all

    merge_request_diff.clean!
  end
end