2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
module MergeRequests
|
|
|
|
class DeleteNonLatestDiffsService
|
|
|
|
BATCH_SIZE = 10
|
|
|
|
|
|
|
|
def initialize(merge_request)
|
|
|
|
@merge_request = merge_request
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
diffs = @merge_request.non_latest_diffs.with_files
|
|
|
|
|
|
|
|
diffs.each_batch(of: BATCH_SIZE) do |relation, index|
|
2019-05-18 00:54:41 +05:30
|
|
|
ids = relation.pluck_primary_key.map { |id| [id] }
|
2018-11-08 19:23:39 +05:30
|
|
|
DeleteDiffFilesWorker.bulk_perform_in(index * 5.minutes, ids)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|