Class: BulkImport
Overview
The BulkImport model links all models required for a bulk import of groups and projects to a GitLab instance. It associates the import with the responsible user.
Constant Summary
collapse
- MIN_MAJOR_VERSION =
14
- MIN_MINOR_VERSION_FOR_PROJECT =
4
- PURGE_CONFIGURATION_DELAY =
24.hours
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
#run_after_commit, #run_after_commit_or_now
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, sharding_keys, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Class Method Details
.all_human_statuses ⇒ Object
82
83
84
|
# File 'app/models/bulk_import.rb', line 82
def self.all_human_statuses
state_machine.states.map(&:human_name)
end
|
.min_gl_version_for_migration_in_batches ⇒ Object
78
79
80
|
# File 'app/models/bulk_import.rb', line 78
def self.min_gl_version_for_migration_in_batches
Gitlab::VersionInfo.new(16, 2)
end
|
.min_gl_version_for_project_migration ⇒ Object
Instance Method Details
#completed? ⇒ Boolean
103
104
105
|
# File 'app/models/bulk_import.rb', line 103
def completed?
finished? || failed? || timeout? || canceled?
end
|
#destination_group_roots ⇒ Object
113
114
115
116
117
|
# File 'app/models/bulk_import.rb', line 113
def destination_group_roots
entities.where(parent: nil).filter_map do |entity|
entity.group || entity.project
end.map(&:root_ancestor).uniq
end
|
#namespaces_with_unassigned_placeholders ⇒ Object
119
120
121
122
123
124
125
126
127
128
|
# File 'app/models/bulk_import.rb', line 119
def namespaces_with_unassigned_placeholders
namespaces = destination_group_roots
namespace_ids = namespaces.collect(&:id)
reassignable_statuses = Import::SourceUser::STATUSES.slice(*Import::SourceUser::REASSIGNABLE_STATUSES).values
source_users = Import::SourceUser.for_namespace(namespace_ids).by_statuses(reassignable_statuses)
valid_namespace_ids = source_users.collect(&:namespace_id).uniq
namespaces.select { |namespace| valid_namespace_ids.include?(namespace.id) }
end
|
#propagate_cancel ⇒ Object
93
94
95
96
97
|
# File 'app/models/bulk_import.rb', line 93
def propagate_cancel
return unless entities.any?
entities.each(&:cancel)
end
|
#schedule_configuration_purge ⇒ Object
#send_completion_notification ⇒ Object
107
108
109
110
111
|
# File 'app/models/bulk_import.rb', line 107
def send_completion_notification
run_after_commit do
Notify.bulk_import_complete(user.id, id).deliver_later
end
end
|
#source_equals_destination? ⇒ Boolean
134
135
136
137
138
139
140
|
# File 'app/models/bulk_import.rb', line 134
def source_equals_destination?
return false unless configuration
source_uri = URI.parse(configuration.url.to_s)
source_uri.host == Settings.gitlab.host
end
|
#source_url ⇒ Object
130
131
132
|
# File 'app/models/bulk_import.rb', line 130
def source_url
configuration&.url
end
|
#source_version_info ⇒ Object
70
71
72
|
# File 'app/models/bulk_import.rb', line 70
def source_version_info
Gitlab::VersionInfo.parse(source_version)
end
|
#supports_batched_export? ⇒ Boolean
99
100
101
|
# File 'app/models/bulk_import.rb', line 99
def supports_batched_export?
source_version_info >= self.class.min_gl_version_for_migration_in_batches
end
|
#update_has_failures ⇒ Object
86
87
88
89
90
91
|
# File 'app/models/bulk_import.rb', line 86
def update_has_failures
return if has_failures
return unless entities.any?(&:has_failures)
update!(has_failures: true)
end
|