Class: MergeRequests::MigrateExternalDiffsService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/merge_requests/migrate_external_diffs_service.rb

Constant Summary collapse

MAX_JOBS =
1000

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #params, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

#initialize(merge_request_diff) ⇒ MigrateExternalDiffsService

Returns a new instance of MigrateExternalDiffsService.



18
19
20
# File 'app/services/merge_requests/migrate_external_diffs_service.rb', line 18

def initialize(merge_request_diff)
  @diff = merge_request_diff
end

Instance Attribute Details

#diffObject (readonly)

Returns the value of attribute diff.



7
8
9
# File 'app/services/merge_requests/migrate_external_diffs_service.rb', line 7

def diff
  @diff
end

Class Method Details

.enqueue!Object



9
10
11
12
13
14
15
16
# File 'app/services/merge_requests/migrate_external_diffs_service.rb', line 9

def self.enqueue!
  ids = MergeRequestDiff.ids_for_external_storage_migration(limit: MAX_JOBS)

  # rubocop:disable Scalability/BulkPerformWithContext
  # https://gitlab.com/gitlab-org/gitlab/issues/202100
  MigrateExternalDiffsWorker.bulk_perform_async(ids.map { |id| [id] })
  # rubocop:enable Scalability/BulkPerformWithContext
end

Instance Method Details

#executeObject



22
23
24
# File 'app/services/merge_requests/migrate_external_diffs_service.rb', line 22

def execute
  diff.migrate_files_to_external_storage!
end